diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index b90e6fcfda..5cd2e4857a 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -802,7 +802,7 @@ public class ClassicPluginStrategy implements PluginStrategy { } } - public static boolean useAntClassLoader = Boolean.getBoolean(ClassicPluginStrategy.class.getName()+".useAntClassLoader"); + public static boolean useAntClassLoader = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName()+".useAntClassLoader"); private static final Logger LOGGER = Logger.getLogger(ClassicPluginStrategy.class.getName()); - public static boolean DISABLE_TRANSFORMER = Boolean.getBoolean(ClassicPluginStrategy.class.getName()+".noBytecodeTransformer"); + public static boolean DISABLE_TRANSFORMER = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName()+".noBytecodeTransformer"); } diff --git a/core/src/main/java/hudson/DNSMultiCast.java b/core/src/main/java/hudson/DNSMultiCast.java index 8d029b6ae3..4d2eb1816d 100644 --- a/core/src/main/java/hudson/DNSMultiCast.java +++ b/core/src/main/java/hudson/DNSMultiCast.java @@ -86,5 +86,5 @@ public class DNSMultiCast implements Closeable { private static final Logger LOGGER = Logger.getLogger(DNSMultiCast.class.getName()); - public static boolean disabled = Boolean.getBoolean(DNSMultiCast.class.getName()+".disabled"); + public static boolean disabled = SystemProperties.getBoolean(DNSMultiCast.class.getName()+".disabled"); } diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 9690c39cd0..536cfe679b 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -2354,7 +2354,7 @@ public final class FilePath implements Serializable { * Default bound for {@link #validateAntFileMask(String, int, boolean)}. * @since 1.592 */ - public static int VALIDATE_ANT_FILE_MASK_BOUND = Integer.getInteger(FilePath.class.getName() + ".VALIDATE_ANT_FILE_MASK_BOUND", 10000); + public static int VALIDATE_ANT_FILE_MASK_BOUND = SystemProperties.getInteger(FilePath.class.getName() + ".VALIDATE_ANT_FILE_MASK_BOUND", 10000); /** * Like {@link #validateAntFileMask(String)} but performing only a bounded number of operations. diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 9f74f42b20..ca26fb0d6f 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -561,7 +561,7 @@ public class Functions { /** * Set to true if you need to use the debug version of YUI. */ - public static boolean DEBUG_YUI = Boolean.getBoolean("debug.YUI"); + public static boolean DEBUG_YUI = SystemProperties.getBoolean("debug.YUI"); /** * Creates a sub map by using the given range (both ends inclusive). @@ -616,7 +616,7 @@ public class Functions { response.addCookie(c); } if (refresh) { - response.addHeader("Refresh", System.getProperty("hudson.Functions.autoRefreshSeconds", "10")); + response.addHeader("Refresh", SystemProperties.getProperty("hudson.Functions.autoRefreshSeconds", "10")); } } @@ -838,7 +838,7 @@ public class Functions { */ public static String getFooterURL() { if(footerURL == null) { - footerURL = System.getProperty("hudson.footerURL"); + footerURL = SystemProperties.getProperty("hudson.footerURL"); if(StringUtils.isBlank(footerURL)) { footerURL = "http://jenkins-ci.org/"; } @@ -1567,10 +1567,6 @@ public class Functions { return projectName; } - public String getSystemProperty(String key) { - return System.getProperty(key); - } - /** * Obtains the host name of the Hudson server that clients can use to talk back to. *

@@ -1772,7 +1768,7 @@ public class Functions { * the permission can't be configured in the security screen). Got it?

*/ public static boolean isArtifactsPermissionEnabled() { - return Boolean.getBoolean("hudson.security.ArtifactsPermission"); + return SystemProperties.getBoolean("hudson.security.ArtifactsPermission"); } /** @@ -1787,7 +1783,7 @@ public class Functions { * control on the "Wipe Out Workspace" action.

*/ public static boolean isWipeOutPermissionEnabled() { - return Boolean.getBoolean("hudson.security.WipeOutPermission"); + return SystemProperties.getBoolean("hudson.security.WipeOutPermission"); } public static String createRenderOnDemandProxy(JellyContext context, String attributesToCapture) { diff --git a/core/src/main/java/hudson/LocalPluginManager.java b/core/src/main/java/hudson/LocalPluginManager.java index 4cfbf6ad93..62aee91afa 100644 --- a/core/src/main/java/hudson/LocalPluginManager.java +++ b/core/src/main/java/hudson/LocalPluginManager.java @@ -60,7 +60,7 @@ public class LocalPluginManager extends PluginManager { @Override protected Collection loadBundledPlugins() { // this is used in tests, when we want to override the default bundled plugins with .jpl (or .hpl) versions - if (System.getProperty("hudson.bundled.plugins") != null) { + if (SystemProperties.getProperty("hudson.bundled.plugins") != null) { return Collections.emptySet(); } diff --git a/core/src/main/java/hudson/Main.java b/core/src/main/java/hudson/Main.java index cf8a168ba1..c1aaab9786 100644 --- a/core/src/main/java/hudson/Main.java +++ b/core/src/main/java/hudson/Main.java @@ -218,10 +218,10 @@ public class Main { /** * Set to true if we are running inside "mvn hpi:run" or "mvn hudson-dev:run" */ - public static boolean isDevelopmentMode = Boolean.getBoolean(Main.class.getName()+".development"); + public static boolean isDevelopmentMode = SystemProperties.getBoolean(Main.class.getName()+".development"); /** * Time out for socket connection to Hudson. */ - public static final int TIMEOUT = Integer.getInteger(Main.class.getName()+".timeout",15000); + public static final int TIMEOUT = SystemProperties.getInteger(Main.class.getName()+".timeout",15000); } diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 2af02aa4c5..d96c68dc20 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -633,7 +633,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas * Creates a hudson.PluginStrategy, looking at the corresponding system property. */ protected PluginStrategy createPluginStrategy() { - String strategyName = System.getProperty(PluginStrategy.class.getName()); + String strategyName = SystemProperties.getProperty(PluginStrategy.class.getName()); if (strategyName != null) { try { Class klazz = getClass().getClassLoader().loadClass(strategyName); @@ -1249,7 +1249,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas private static final Logger LOGGER = Logger.getLogger(PluginManager.class.getName()); - public static boolean FAST_LOOKUP = !Boolean.getBoolean(PluginManager.class.getName()+".noFastLookup"); + public static boolean FAST_LOOKUP = !SystemProperties.getBoolean(PluginManager.class.getName()+".noFastLookup"); public static final Permission UPLOAD_PLUGINS = new Permission(Jenkins.PERMISSIONS, "UploadPlugins", Messages._PluginManager_UploadPluginsPermission_Description(),Jenkins.ADMINISTER,PermissionScope.JENKINS); public static final Permission CONFIGURE_UPDATECENTER = new Permission(Jenkins.PERMISSIONS, "ConfigureUpdateCenter", Messages._PluginManager_ConfigureUpdateCenterPermission_Description(),Jenkins.ADMINISTER,PermissionScope.JENKINS); diff --git a/core/src/main/java/hudson/SystemProperties.java b/core/src/main/java/hudson/SystemProperties.java new file mode 100644 index 0000000000..88fa83163f --- /dev/null +++ b/core/src/main/java/hudson/SystemProperties.java @@ -0,0 +1,220 @@ +/* + * The MIT License + * + * Copyright 2015 Johannes Ernst, http://upon2020.com/. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson; + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletContext; + +/** + * Centralizes calls to System.getProperty() and related calls. + * This allows us to get values not just from environment variables but also from + * the ServletContext, so things like hudson.DNSMultiCast.disabled can be set + * in context.xml and the app server's boot script does not have to be changed. + * + * While it looks like it on first glamce, this cannot be mapped to EnvVars.java + * because EnvVars.java is only for build variables, not Jenkins itself variables. + * + * This should be invoked for hudson parameters (e.g. hudson.DNSMultiCast.disabled), + * but not for system parameters (e.g. os.name). + * + * @author Johannes Ernst + */ +public class SystemProperties { + /** + * The ServletContext to get the init parameters from. + */ + private static ServletContext theContext; + + /** + * Logger. + */ + private static final Logger LOGGER = Logger.getLogger(SystemProperties.class.getName()); + + /** + * Gets the system property indicated by the specified key. + * This behaves just like System.getProperty(String), except that it + * also consults the ServletContext's init parameters. + * + * @param key the name of the system property. + * @return the string value of the system property, + * or null if there is no property with that key. + * + * @exception SecurityException if a security manager exists and its + * checkPropertyAccess method doesn't allow + * access to the specified system property. + * @exception NullPointerException if key is + * null. + * @exception IllegalArgumentException if key is empty. + */ + public static String getProperty(String key) { + String value = System.getProperty(key); // keep passing on any exceptions + if( value != null ) { + if( LOGGER.isLoggable(Level.INFO )) { + LOGGER.log(Level.INFO, "Property (system): {0} => {1}", new Object[]{ key, value }); + } + } else if( theContext != null ) { + value = theContext.getInitParameter(key); + if( value != null ) { + if( LOGGER.isLoggable(Level.INFO )) { + LOGGER.log(Level.INFO, "Property (context): {0} => {1}", new Object[]{ key, value }); + } + } + } else { + if( LOGGER.isLoggable(Level.INFO )) { + LOGGER.log(Level.INFO, "Property (not found): {0} => {1}", new Object[]{ key, value }); + } + } + + return value; + } + + /** + * Gets the system property indicated by the specified key. + * This behaves just like System.getProperty(String), except that it + * also consults the ServletContext's init parameters. + * + * @param key the name of the system property. + * @param def a default value. + * @return the string value of the system property, + * or null if there is no property with that key. + * + * @exception SecurityException if a security manager exists and its + * checkPropertyAccess method doesn't allow + * access to the specified system property. + * @exception NullPointerException if key is + * null. + * @exception IllegalArgumentException if key is empty. + */ + public static String getProperty(String key, String def) { + String value = System.getProperty(key); // keep passing on any exceptions + if( value != null ) { + if( LOGGER.isLoggable(Level.INFO )) { + LOGGER.log(Level.INFO, "Property (system): {0} => {1}", new Object[]{ key, value }); + } + } else if( theContext != null ) { + value = theContext.getInitParameter(key); + if( value != null ) { + if( LOGGER.isLoggable(Level.INFO )) { + LOGGER.log(Level.INFO, "Property (context): {0} => {1}", new Object[]{ key, value }); + } + } + } + if( value == null ) { + value = def; + if( LOGGER.isLoggable(Level.INFO )) { + LOGGER.log(Level.INFO, "Property (default): {0} => {1}", new Object[]{ key, value }); + } + } + return value; + } + + /** + * Returns {@code true} if the system property + * named by the argument exists and is equal to the string + * {@code "true"}. If the system property does not exist, return + * {@code "true"} if a property by this name exists in the servletcontext + * and is equal to the string {@code "true"}. + * + * This behaves just like Boolean.getBoolean(String), except that it + * also consults the ServletContext's init parameters. + * + * @param name the system property name. + * @return the {@code boolean} value of the system property. + */ + public static boolean getBoolean(String name) { + return getBoolean(name, false); + } + + /** + * Returns {@code true} if the system property + * named by the argument exists and is equal to the string + * {@code "true"}. If the system property does not exist, return + * {@code "true"} if a property by this name exists in the servletcontext + * and is equal to the string {@code "true"}. If that property does not + * exist either, return the default value. + * + * This behaves just like Boolean.getBoolean(String), except that it + * also consults the ServletContext's init parameters. + * + * @param name the system property name. + * @param def a default value. + * @return the {@code boolean} value of the system property. + */ + public static boolean getBoolean(String name, boolean def) { + String v = getProperty(name); + + if (v != null) { + return Boolean.parseBoolean(v); + } + return def; + } + + /** + * Determines the integer value of the system property with the + * specified name. + * + * This behaves just like Integer.getInteger(String), except that it + * also consults the ServletContext's init parameters. + * + * @param name property name. + * @return the {@code Integer} value of the property. + */ + public static Integer getInteger(String name) { + return getInteger( name, null ); + } + + /** + * Determines the integer value of the system property with the + * specified name. + * + * This behaves just like Integer.getInteger(String), except that it + * also consults the ServletContext's init parameters. If neither exist, + * return the default value. + * + * @param name property name. + * @param def a default value. + * @return the {@code Integer} value of the property. + */ + + public static Integer getInteger(String name, Integer def) { + String v = getProperty(name); + + if (v != null) { + try { + return Integer.decode(v); + } catch (NumberFormatException e) { + } + } + return def; + } + /** + * Invoked by WebAppMain, tells us where to get the init parameters from. + * + * @param context the ServletContext obtained from contextInitialized + */ + public static void initialize(ServletContext context) { + theContext = context; + } +} diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index 46d99076ae..7fe14e0496 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -203,7 +203,7 @@ public final class TcpSlaveAgentListener extends Thread { * * TODO: think about how to expose this (including whether this needs to be exposed at all.) */ - public static String CLI_HOST_NAME = System.getProperty(TcpSlaveAgentListener.class.getName()+".hostName"); + public static String CLI_HOST_NAME = SystemProperties.getProperty(TcpSlaveAgentListener.class.getName()+".hostName"); /** * Port number that we advertise the CLI client to connect to. @@ -215,7 +215,7 @@ public final class TcpSlaveAgentListener extends Thread { * * @since 1.611 */ - public static Integer CLI_PORT = Integer.getInteger(TcpSlaveAgentListener.class.getName()+".port"); + public static Integer CLI_PORT = SystemProperties.getInteger(TcpSlaveAgentListener.class.getName()+".port"); } /* diff --git a/core/src/main/java/hudson/UDPBroadcastThread.java b/core/src/main/java/hudson/UDPBroadcastThread.java index ebc6eb9e1b..bb9b5aa708 100644 --- a/core/src/main/java/hudson/UDPBroadcastThread.java +++ b/core/src/main/java/hudson/UDPBroadcastThread.java @@ -125,7 +125,7 @@ public class UDPBroadcastThread extends Thread { interrupt(); } - public static final int PORT = Integer.getInteger("hudson.udp",33848); + public static final int PORT = SystemProperties.getInteger("hudson.udp",33848); private static final Logger LOGGER = Logger.getLogger(UDPBroadcastThread.class.getName()); diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index e9297a83eb..c3c649dc48 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -1525,7 +1525,7 @@ public class Util { /** * On Unix environment that cannot run "ln", set this to true. */ - public static boolean NO_SYMLINK = Boolean.getBoolean(Util.class.getName()+".noSymLink"); + public static boolean NO_SYMLINK = SystemProperties.getBoolean(Util.class.getName()+".noSymLink"); - public static boolean SYMLINK_ESCAPEHATCH = Boolean.getBoolean(Util.class.getName()+".symlinkEscapeHatch"); + public static boolean SYMLINK_ESCAPEHATCH = SystemProperties.getBoolean(Util.class.getName()+".symlinkEscapeHatch"); } diff --git a/core/src/main/java/hudson/WebAppMain.java b/core/src/main/java/hudson/WebAppMain.java index 11d438d5ab..99bdef5641 100644 --- a/core/src/main/java/hudson/WebAppMain.java +++ b/core/src/main/java/hudson/WebAppMain.java @@ -117,6 +117,8 @@ public class WebAppMain implements ServletContextListener { installLogger(); + SystemProperties.initialize( event.getServletContext() ); + markCookieAsHttpOnly(context); final FileAndDescription describedHomeDir = getHomeDir(event); @@ -357,9 +359,9 @@ public class WebAppMain implements ServletContextListener { // next the system property for (String name : HOME_NAMES) { - String sysProp = System.getProperty(name); + String sysProp = SystemProperties.getProperty(name); if(sysProp!=null) - return new FileAndDescription(new File(sysProp.trim()),"System.getProperty(\""+name+"\")"); + return new FileAndDescription(new File(sysProp.trim()),"SystemProperties.getProperty(\""+name+"\")"); } // look at the env var next diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index 2c68b0f6ff..d18a66464c 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -29,6 +29,7 @@ import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.cli.declarative.CLIMethod; import hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson; +import hudson.SystemProperties; import hudson.cli.declarative.OptionHandlerExtension; import jenkins.model.Jenkins; import hudson.remoting.Callable; @@ -418,7 +419,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable { } public String call() throws IOException { - return System.getProperty(name); + return SystemProperties.getProperty(name); } private static final long serialVersionUID = 1L; diff --git a/core/src/main/java/hudson/init/InitStrategy.java b/core/src/main/java/hudson/init/InitStrategy.java index 7b8497405d..1ba014597d 100644 --- a/core/src/main/java/hudson/init/InitStrategy.java +++ b/core/src/main/java/hudson/init/InitStrategy.java @@ -15,6 +15,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import hudson.PluginManager; +import hudson.SystemProperties; import hudson.util.DirScanner; import hudson.util.FileVisitor; import hudson.util.Service; @@ -84,7 +85,7 @@ public class InitStrategy { * TODO: maven-hpi-plugin should inject its own InitStrategy instead of having this in the core. */ protected void getBundledPluginsFromProperty(final List r) { - String hplProperty = System.getProperty("hudson.bundled.plugins"); + String hplProperty = SystemProperties.getProperty("hudson.bundled.plugins"); if (hplProperty != null) { for (String hplLocation : hplProperty.split(",")) { File hpl = new File(hplLocation.trim()); diff --git a/core/src/main/java/hudson/lifecycle/Lifecycle.java b/core/src/main/java/hudson/lifecycle/Lifecycle.java index d314742f85..b768cc545c 100644 --- a/core/src/main/java/hudson/lifecycle/Lifecycle.java +++ b/core/src/main/java/hudson/lifecycle/Lifecycle.java @@ -25,6 +25,7 @@ package hudson.lifecycle; import hudson.ExtensionPoint; import hudson.Functions; +import hudson.SystemProperties; import hudson.Util; import jenkins.model.Jenkins; @@ -57,7 +58,7 @@ public abstract class Lifecycle implements ExtensionPoint { public synchronized static Lifecycle get() { if(INSTANCE==null) { Lifecycle instance; - String p = System.getProperty("hudson.lifecycle"); + String p = SystemProperties.getProperty("hudson.lifecycle"); if(p!=null) { try { ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader; @@ -119,7 +120,7 @@ public abstract class Lifecycle implements ExtensionPoint { * to a newer version. */ public File getHudsonWar() { - String war = System.getProperty("executable-war"); + String war = SystemProperties.getProperty("executable-war"); if(war!=null && new File(war).exists()) return new File(war); return null; diff --git a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java index 4401b43649..afef84e84e 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java +++ b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java @@ -34,6 +34,7 @@ import hudson.util.jna.Shell32; import jenkins.model.Jenkins; import hudson.AbortException; import hudson.Extension; +import hudson.SystemProperties; import hudson.util.StreamTaskListener; import hudson.util.jna.DotNet; import org.apache.commons.io.IOUtils; @@ -257,14 +258,14 @@ public class WindowsInstallerLink extends ManagementLink { // this system property is set by the launcher when we run "java -jar jenkins.war" // and this is how we know where is jenkins.war. - String war = System.getProperty("executable-war"); + String war = SystemProperties.getProperty("executable-war"); if(war!=null && new File(war).exists()) { WindowsInstallerLink link = new WindowsInstallerLink(new File(war)); // in certain situations where we know the user is just trying Jenkins (like when Jenkins is launched // from JNLP), also put this link on the navigation bar to increase // visibility - if(System.getProperty(WindowsInstallerLink.class.getName()+".prominent")!=null) + if(SystemProperties.getProperty(WindowsInstallerLink.class.getName()+".prominent")!=null) Jenkins.getInstance().getActions().add(link); return link; diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index e9c4626706..bb55d86198 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -30,6 +30,7 @@ import hudson.EnvVars; import hudson.FilePath; import hudson.Functions; import hudson.Launcher; +import hudson.SystemProperties; import hudson.console.ModelHyperlinkNote; import hudson.model.Fingerprint.BuildPtr; import hudson.model.Fingerprint.RangeSet; @@ -106,7 +107,7 @@ public abstract class AbstractBuild

,R extends Abs /** * Set if we want the blame information to flow from upstream to downstream build. */ - private static final boolean upstreamCulprits = Boolean.getBoolean("hudson.upstreamCulprits"); + private static final boolean upstreamCulprits = SystemProperties.getBoolean("hudson.upstreamCulprits"); /** * Name of the slave this project was built on. diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index 547e51c753..f221a396d1 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -29,6 +29,7 @@ import edu.umd.cs.findbugs.annotations.When; import hudson.EnvVars; import hudson.Extension; import hudson.Launcher.ProcStarter; +import hudson.SystemProperties; import hudson.Util; import hudson.cli.declarative.CLIMethod; import hudson.cli.declarative.CLIResolver; @@ -1272,7 +1273,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces private static class GetFallbackName extends MasterToSlaveCallable { public String call() throws IOException { - return System.getProperty("host.name"); + return SystemProperties.getProperty("host.name"); } private static final long serialVersionUID = 1L; } @@ -1693,7 +1694,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces /** * @since 1.532 */ - public static final Permission EXTENDED_READ = new Permission(PERMISSIONS,"ExtendedRead", Messages._Computer_ExtendedReadPermission_Description(), CONFIGURE, Boolean.getBoolean("hudson.security.ExtendedReadPermission"), new PermissionScope[]{PermissionScope.COMPUTER}); + public static final Permission EXTENDED_READ = new Permission(PERMISSIONS,"ExtendedRead", Messages._Computer_ExtendedReadPermission_Description(), CONFIGURE, SystemProperties.getBoolean("hudson.security.ExtendedReadPermission"), new PermissionScope[]{PermissionScope.COMPUTER}); public static final Permission DELETE = new Permission(PERMISSIONS,"Delete", Messages._Computer_DeletePermission_Description(), Permission.DELETE, PermissionScope.COMPUTER); public static final Permission CREATE = new Permission(PERMISSIONS,"Create", Messages._Computer_CreatePermission_Description(), Permission.CREATE, PermissionScope.COMPUTER); public static final Permission DISCONNECT = new Permission(PERMISSIONS,"Disconnect", Messages._Computer_DisconnectPermission_Description(), Jenkins.ADMINISTER, PermissionScope.COMPUTER); diff --git a/core/src/main/java/hudson/model/DownloadService.java b/core/src/main/java/hudson/model/DownloadService.java index 905199581c..359ff186bf 100644 --- a/core/src/main/java/hudson/model/DownloadService.java +++ b/core/src/main/java/hudson/model/DownloadService.java @@ -28,6 +28,7 @@ import hudson.ExtensionList; import hudson.ExtensionListListener; import hudson.ExtensionPoint; import hudson.ProxyConfiguration; +import hudson.SystemProperties; import hudson.init.InitMilestone; import hudson.init.Initializer; import hudson.util.FormValidation; @@ -408,7 +409,7 @@ public class DownloadService extends PageDecorator { Long.getLong(Downloadable.class.getName()+".defaultInterval", DAYS.toMillis(1)); } - public static boolean neverUpdate = Boolean.getBoolean(DownloadService.class.getName()+".never"); + public static boolean neverUpdate = SystemProperties.getBoolean(DownloadService.class.getName()+".never"); /** * May be used to temporarily disable signature checking on {@link DownloadService} and {@link UpdateCenter}. @@ -416,6 +417,6 @@ public class DownloadService extends PageDecorator { * Should only be used when {@link DownloadSettings#isUseBrowser}; * disabling signature checks for in-browser downloads is very dangerous as unprivileged users could submit spoofed metadata! */ - public static boolean signatureCheck = !Boolean.getBoolean(DownloadService.class.getName()+".noSignatureCheck"); + public static boolean signatureCheck = !SystemProperties.getBoolean(DownloadService.class.getName()+".noSignatureCheck"); } diff --git a/core/src/main/java/hudson/model/FullDuplexHttpChannel.java b/core/src/main/java/hudson/model/FullDuplexHttpChannel.java index e967188901..872c6f9dc3 100644 --- a/core/src/main/java/hudson/model/FullDuplexHttpChannel.java +++ b/core/src/main/java/hudson/model/FullDuplexHttpChannel.java @@ -23,6 +23,7 @@ */ package hudson.model; +import hudson.SystemProperties; import hudson.remoting.Channel; import hudson.remoting.PingThread; import hudson.remoting.Channel.Mode; @@ -153,7 +154,7 @@ abstract public class FullDuplexHttpChannel { * Set to true if the servlet container doesn't support chunked encoding. */ @Restricted(NoExternalUse.class) - public static boolean DIY_CHUNKING = Boolean.getBoolean("hudson.diyChunking"); + public static boolean DIY_CHUNKING = SystemProperties.getBoolean("hudson.diyChunking"); /** * Controls the time out of waiting for the 2nd HTTP request to arrive. diff --git a/core/src/main/java/hudson/model/Item.java b/core/src/main/java/hudson/model/Item.java index 94ee4181de..50a8b23b38 100644 --- a/core/src/main/java/hudson/model/Item.java +++ b/core/src/main/java/hudson/model/Item.java @@ -25,6 +25,7 @@ package hudson.model; import hudson.Functions; +import hudson.SystemProperties; import hudson.security.PermissionScope; import org.kohsuke.stapler.StaplerRequest; @@ -226,7 +227,7 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont Permission CONFIGURE = new Permission(PERMISSIONS, "Configure", Messages._Item_CONFIGURE_description(), Permission.CONFIGURE, PermissionScope.ITEM); Permission READ = new Permission(PERMISSIONS, "Read", Messages._Item_READ_description(), Permission.READ, PermissionScope.ITEM); Permission DISCOVER = new Permission(PERMISSIONS, "Discover", Messages._AbstractProject_DiscoverPermission_Description(), READ, PermissionScope.ITEM); - Permission EXTENDED_READ = new Permission(PERMISSIONS,"ExtendedRead", Messages._AbstractProject_ExtendedReadPermission_Description(), CONFIGURE, Boolean.getBoolean("hudson.security.ExtendedReadPermission"), new PermissionScope[]{PermissionScope.ITEM}); + Permission EXTENDED_READ = new Permission(PERMISSIONS,"ExtendedRead", Messages._AbstractProject_ExtendedReadPermission_Description(), CONFIGURE, SystemProperties.getBoolean("hudson.security.ExtendedReadPermission"), new PermissionScope[]{PermissionScope.ITEM}); // TODO the following really belong in Job, not Item, but too late to move since the owner.name is encoded in the ID: Permission BUILD = new Permission(PERMISSIONS, "Build", Messages._AbstractProject_BuildPermission_Description(), Permission.UPDATE, PermissionScope.ITEM); Permission WORKSPACE = new Permission(PERMISSIONS, "Workspace", Messages._AbstractProject_WorkspacePermission_Description(), Permission.READ, PermissionScope.ITEM); diff --git a/core/src/main/java/hudson/model/LoadStatistics.java b/core/src/main/java/hudson/model/LoadStatistics.java index cd72f87b7a..c905c4ab4e 100644 --- a/core/src/main/java/hudson/model/LoadStatistics.java +++ b/core/src/main/java/hudson/model/LoadStatistics.java @@ -24,6 +24,7 @@ package hudson.model; import hudson.Extension; +import hudson.SystemProperties; import hudson.model.MultiStageTimeSeries.TimeScale; import hudson.model.MultiStageTimeSeries.TrendChart; import hudson.model.queue.SubTask; @@ -371,11 +372,11 @@ public abstract class LoadStatistics { * * Put differently, the half reduction time is {@code CLOCK*log(0.5)/log(DECAY)} */ - public static final float DECAY = Float.parseFloat(System.getProperty(LoadStatistics.class.getName()+".decay","0.9")); + public static final float DECAY = Float.parseFloat(SystemProperties.getProperty(LoadStatistics.class.getName()+".decay","0.9")); /** * Load statistics clock cycle in milliseconds. Specify a small value for quickly debugging this feature and node provisioning through cloud. */ - public static int CLOCK = Integer.getInteger(LoadStatistics.class.getName() + ".clock", 10 * 1000); + public static int CLOCK = SystemProperties.getInteger(LoadStatistics.class.getName() + ".clock", 10 * 1000); /** * Periodically update the load statistics average. diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 3152d08006..df5c002c8d 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -123,6 +123,7 @@ import org.kohsuke.accmod.restrictions.DoNotUse; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter; +import hudson.SystemProperties; import javax.annotation.CheckForNull; import javax.annotation.Nonnegative; import jenkins.model.queue.AsynchronousExecution; @@ -174,7 +175,7 @@ public class Queue extends ResourceController implements Saveable { * Data should be defined in milliseconds, default value - 1000; * @since 1.577 */ - private static int CACHE_REFRESH_PERIOD = Integer.getInteger(Queue.class.getName() + ".cacheRefreshPeriod", 1000); + private static int CACHE_REFRESH_PERIOD = SystemProperties.getInteger(Queue.class.getName() + ".cacheRefreshPeriod", 1000); /** * Items that are waiting for its quiet period to pass. diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index c4f64ccade..bf77d9fc52 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -36,6 +36,7 @@ import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.FeedAdapter; import hudson.Functions; +import hudson.SystemProperties; import hudson.Util; import hudson.XmlFile; import hudson.cli.declarative.CLIMethod; @@ -45,6 +46,7 @@ import hudson.model.Run.RunExecution; import hudson.model.listeners.RunListener; import hudson.model.listeners.SaveableListener; import hudson.model.queue.Executables; +import hudson.model.queue.SubTask; import hudson.search.SearchIndexBuilder; import hudson.security.ACL; import hudson.security.AccessControlled; @@ -103,6 +105,7 @@ import jenkins.model.PeepholePermalink; import jenkins.model.RunAction2; import jenkins.model.StandardArtifactManager; import jenkins.model.lazy.BuildReference; +import jenkins.model.lazy.LazyBuildMixIn; import jenkins.util.VirtualFile; import jenkins.util.io.OnMaster; import net.sf.json.JSONObject; @@ -1137,12 +1140,12 @@ public abstract class Run ,RunT extends Run, RunT extends Run< * when explicitly requested. * */ - public static boolean reloadPeriodically = Boolean.getBoolean(ViewJob.class.getName()+".reloadPeriodically"); + public static boolean reloadPeriodically = SystemProperties.getBoolean(ViewJob.class.getName()+".reloadPeriodically"); } diff --git a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java index 9e83e143e5..875bbfb8f1 100644 --- a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java +++ b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java @@ -26,6 +26,7 @@ package hudson.model; import hudson.Extension; import hudson.ExtensionList; import hudson.FilePath; +import hudson.SystemProperties; import hudson.Util; import java.io.IOException; import java.util.ArrayList; @@ -143,15 +144,15 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork { /** * Can be used to disable workspace clean up. */ - public static boolean disabled = Boolean.getBoolean(WorkspaceCleanupThread.class.getName()+".disabled"); + public static boolean disabled = SystemProperties.getBoolean(WorkspaceCleanupThread.class.getName()+".disabled"); /** * How often the clean up should run. This is final as Jenkins will not reflect changes anyway. */ - public static final int recurrencePeriodHours = Integer.getInteger(WorkspaceCleanupThread.class.getName()+".recurrencePeriodHours", 24); + public static final int recurrencePeriodHours = SystemProperties.getInteger(WorkspaceCleanupThread.class.getName()+".recurrencePeriodHours", 24); /** * Number of days workspaces should be retained. */ - public static int retainForDays = Integer.getInteger(WorkspaceCleanupThread.class.getName()+".retainForDays", 30); + public static int retainForDays = SystemProperties.getInteger(WorkspaceCleanupThread.class.getName()+".retainForDays", 30); } diff --git a/core/src/main/java/hudson/model/queue/BackFiller.java b/core/src/main/java/hudson/model/queue/BackFiller.java index 0eeea61670..2a456e099e 100644 --- a/core/src/main/java/hudson/model/queue/BackFiller.java +++ b/core/src/main/java/hudson/model/queue/BackFiller.java @@ -2,6 +2,7 @@ package hudson.model.queue; import com.google.common.collect.Iterables; import hudson.Extension; +import hudson.SystemProperties; import hudson.model.Computer; import hudson.model.Executor; import jenkins.model.Jenkins; @@ -204,7 +205,7 @@ public class BackFiller extends LoadPredictor { */ @Extension public static BackFiller newInstance() { - if (Boolean.getBoolean(BackFiller.class.getName())) + if (SystemProperties.getBoolean(BackFiller.class.getName())) return new BackFiller(); return null; } diff --git a/core/src/main/java/hudson/os/solaris/ZFSInstaller.java b/core/src/main/java/hudson/os/solaris/ZFSInstaller.java index 94ff9638d8..13bea8be2c 100644 --- a/core/src/main/java/hudson/os/solaris/ZFSInstaller.java +++ b/core/src/main/java/hudson/os/solaris/ZFSInstaller.java @@ -28,6 +28,7 @@ import com.sun.akuma.JavaVMArguments; import hudson.Launcher.LocalLauncher; import hudson.Util; import hudson.Extension; +import hudson.SystemProperties; import hudson.os.SU; import hudson.model.AdministrativeMonitor; import jenkins.model.Jenkins; @@ -282,7 +283,7 @@ public class ZFSInstaller extends AdministrativeMonitor implements Serializable @Extension public static AdministrativeMonitor init() { - String migrationTarget = System.getProperty(ZFSInstaller.class.getName() + ".migrate"); + String migrationTarget = SystemProperties.getProperty(ZFSInstaller.class.getName() + ".migrate"); if(migrationTarget!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamTaskListener listener = new StreamTaskListener(new ForkOutputStream(System.out, out)); @@ -436,5 +437,5 @@ public class ZFSInstaller extends AdministrativeMonitor implements Serializable /** * Escape hatch in case JNI calls fatally crash, like in HUDSON-3733. */ - public static boolean disabled = Boolean.getBoolean(ZFSInstaller.class.getName()+".disabled"); + public static boolean disabled = SystemProperties.getBoolean(ZFSInstaller.class.getName()+".disabled"); } diff --git a/core/src/main/java/hudson/scheduler/BaseParser.java b/core/src/main/java/hudson/scheduler/BaseParser.java index 476bc41e5e..b89f7ca7de 100644 --- a/core/src/main/java/hudson/scheduler/BaseParser.java +++ b/core/src/main/java/hudson/scheduler/BaseParser.java @@ -31,6 +31,7 @@ import antlr.Token; import antlr.TokenBuffer; import antlr.TokenStream; import antlr.TokenStreamException; +import hudson.SystemProperties; /** * @author Kohsuke Kawaguchi @@ -145,7 +146,7 @@ abstract class BaseParser extends LLkParser { /** * This property hashes tokens in the cron tab tokens like @daily so that they spread evenly. */ - public static boolean HASH_TOKENS = !"false".equals(System.getProperty(BaseParser.class.getName()+".hash")); + public static boolean HASH_TOKENS = !"false".equals(SystemProperties.getProperty(BaseParser.class.getName()+".hash")); /** * Constant that indicates no step value. diff --git a/core/src/main/java/hudson/security/csrf/DefaultCrumbIssuer.java b/core/src/main/java/hudson/security/csrf/DefaultCrumbIssuer.java index b801866fa6..145d6fc632 100644 --- a/core/src/main/java/hudson/security/csrf/DefaultCrumbIssuer.java +++ b/core/src/main/java/hudson/security/csrf/DefaultCrumbIssuer.java @@ -11,6 +11,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import hudson.Extension; +import hudson.SystemProperties; import hudson.Util; import jenkins.model.Jenkins; import hudson.model.ModelObject; @@ -121,7 +122,7 @@ public class DefaultCrumbIssuer extends CrumbIssuer { private final static HexStringConfidentialKey CRUMB_SALT = new HexStringConfidentialKey(Jenkins.class,"crumbSalt",16); public DescriptorImpl() { - super(CRUMB_SALT.get(), System.getProperty("hudson.security.csrf.requestfield", ".crumb")); + super(CRUMB_SALT.get(), SystemProperties.getProperty("hudson.security.csrf.requestfield", ".crumb")); load(); } diff --git a/core/src/main/java/hudson/slaves/ChannelPinger.java b/core/src/main/java/hudson/slaves/ChannelPinger.java index 49ae7c1cf9..f8f1faa36c 100644 --- a/core/src/main/java/hudson/slaves/ChannelPinger.java +++ b/core/src/main/java/hudson/slaves/ChannelPinger.java @@ -25,6 +25,7 @@ package hudson.slaves; import hudson.Extension; import hudson.FilePath; +import hudson.SystemProperties; import hudson.model.Computer; import hudson.model.Slave; import hudson.model.TaskListener; @@ -57,7 +58,7 @@ public class ChannelPinger extends ComputerListener { private int pingInterval = 5; public ChannelPinger() { - String interval = System.getProperty(SYS_PROPERTY_NAME); + String interval = SystemProperties.getProperty(SYS_PROPERTY_NAME); if (interval != null) { try { pingInterval = Integer.valueOf(interval); diff --git a/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java b/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java index 054a13b6ac..48cfed1f7b 100644 --- a/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java +++ b/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java @@ -24,6 +24,7 @@ package hudson.slaves; +import hudson.SystemProperties; import javax.annotation.concurrent.GuardedBy; import java.io.IOException; import java.util.logging.Logger; @@ -76,5 +77,5 @@ public class CloudRetentionStrategy extends RetentionStrategy { diff --git a/core/src/main/java/hudson/slaves/NodeProvisioner.java b/core/src/main/java/hudson/slaves/NodeProvisioner.java index 216c8b3ef1..91ca1ee49d 100644 --- a/core/src/main/java/hudson/slaves/NodeProvisioner.java +++ b/core/src/main/java/hudson/slaves/NodeProvisioner.java @@ -30,6 +30,7 @@ import jenkins.model.Jenkins; import static hudson.model.LoadStatistics.DECAY; import hudson.model.MultiStageTimeSeries.TimeScale; import hudson.Extension; +import hudson.SystemProperties; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; @@ -778,8 +779,8 @@ public class NodeProvisioner { * Give some initial warm up time so that statically connected slaves * can be brought online before we start allocating more. */ - public static int INITIALDELAY = Integer.getInteger(NodeProvisioner.class.getName()+".initialDelay",LoadStatistics.CLOCK*10); - public static int RECURRENCEPERIOD = Integer.getInteger(NodeProvisioner.class.getName()+".recurrencePeriod",LoadStatistics.CLOCK); + public static int INITIALDELAY = SystemProperties.getInteger(NodeProvisioner.class.getName()+".initialDelay",LoadStatistics.CLOCK*10); + public static int RECURRENCEPERIOD = SystemProperties.getInteger(NodeProvisioner.class.getName()+".recurrencePeriod",LoadStatistics.CLOCK); @Override public long getInitialDelay() { @@ -800,7 +801,7 @@ public class NodeProvisioner { } private static final Logger LOGGER = Logger.getLogger(NodeProvisioner.class.getName()); - private static final float MARGIN = Integer.getInteger(NodeProvisioner.class.getName()+".MARGIN",10)/100f; + private static final float MARGIN = SystemProperties.getInteger(NodeProvisioner.class.getName()+".MARGIN",10)/100f; private static final float MARGIN0 = Math.max(MARGIN, getFloatSystemProperty(NodeProvisioner.class.getName()+".MARGIN0",0.5f)); private static final float MARGIN_DECAY = getFloatSystemProperty(NodeProvisioner.class.getName()+".MARGIN_DECAY",0.5f); @@ -808,7 +809,7 @@ public class NodeProvisioner { private static final TimeScale TIME_SCALE = TimeScale.SEC10; private static float getFloatSystemProperty(String propName, float defaultValue) { - String v = System.getProperty(propName); + String v = SystemProperties.getProperty(propName); if (v!=null) try { return Float.parseFloat(v); diff --git a/core/src/main/java/hudson/slaves/WorkspaceList.java b/core/src/main/java/hudson/slaves/WorkspaceList.java index a344b45aac..632d8e4598 100644 --- a/core/src/main/java/hudson/slaves/WorkspaceList.java +++ b/core/src/main/java/hudson/slaves/WorkspaceList.java @@ -25,6 +25,7 @@ package hudson.slaves; import hudson.FilePath; import hudson.Functions; +import hudson.SystemProperties; import hudson.model.Computer; import java.io.Closeable; @@ -288,5 +289,5 @@ public final class WorkspaceList { /** * The token that combines the project name and unique number to create unique workspace directory. */ - private static final String COMBINATOR = System.getProperty(WorkspaceList.class.getName(),"@"); + private static final String COMBINATOR = SystemProperties.getProperty(WorkspaceList.class.getName(),"@"); } diff --git a/core/src/main/java/hudson/tasks/ArtifactArchiver.java b/core/src/main/java/hudson/tasks/ArtifactArchiver.java index 297300b525..87631e86b9 100644 --- a/core/src/main/java/hudson/tasks/ArtifactArchiver.java +++ b/core/src/main/java/hudson/tasks/ArtifactArchiver.java @@ -28,6 +28,7 @@ import jenkins.MasterToSlaveFileCallable; import hudson.Launcher; import hudson.Util; import hudson.Extension; +import hudson.SystemProperties; import hudson.model.AbstractProject; import hudson.model.Result; import hudson.model.Run; @@ -137,7 +138,7 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep { // Backwards compatibility for older builds public Object readResolve() { if (allowEmptyArchive == null) { - this.allowEmptyArchive = Boolean.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty"); + this.allowEmptyArchive = SystemProperties.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty"); } if (defaultExcludes == null){ defaultExcludes = true; diff --git a/core/src/main/java/hudson/tasks/Fingerprinter.java b/core/src/main/java/hudson/tasks/Fingerprinter.java index 051809dfca..9dc89d7cee 100644 --- a/core/src/main/java/hudson/tasks/Fingerprinter.java +++ b/core/src/main/java/hudson/tasks/Fingerprinter.java @@ -29,6 +29,7 @@ import hudson.Extension; import hudson.FilePath; import jenkins.MasterToSlaveFileCallable; import hudson.Launcher; +import hudson.SystemProperties; import hudson.Util; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; @@ -82,7 +83,7 @@ import jenkins.tasks.SimpleBuildStep; * @author Kohsuke Kawaguchi */ public class Fingerprinter extends Recorder implements Serializable, DependencyDeclarer, SimpleBuildStep { - public static boolean enableFingerprintsInDependencyGraph = Boolean.getBoolean(Fingerprinter.class.getName() + ".enableFingerprintsInDependencyGraph"); + public static boolean enableFingerprintsInDependencyGraph = SystemProperties.getBoolean(Fingerprinter.class.getName() + ".enableFingerprintsInDependencyGraph"); /** * Comma-separated list of files/directories to be fingerprinted. diff --git a/core/src/main/java/hudson/util/CharacterEncodingFilter.java b/core/src/main/java/hudson/util/CharacterEncodingFilter.java index f9ddffc2b3..6d0def96f7 100644 --- a/core/src/main/java/hudson/util/CharacterEncodingFilter.java +++ b/core/src/main/java/hudson/util/CharacterEncodingFilter.java @@ -23,6 +23,7 @@ */ package hudson.util; +import hudson.SystemProperties; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; @@ -48,13 +49,13 @@ public class CharacterEncodingFilter implements Filter { private static final String ENCODING = "UTF-8"; private static final Boolean DISABLE_FILTER - = Boolean.getBoolean(CharacterEncodingFilter.class.getName() + ".disableFilter"); + = SystemProperties.getBoolean(CharacterEncodingFilter.class.getName() + ".disableFilter"); /** * The character encoding sets forcibly? */ private static final Boolean FORCE_ENCODING - = Boolean.getBoolean(CharacterEncodingFilter.class.getName() + ".forceEncoding"); + = SystemProperties.getBoolean(CharacterEncodingFilter.class.getName() + ".forceEncoding"); public void init(FilterConfig filterConfig) throws ServletException { LOGGER.log(Level.FINE, diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index dd5a3d756b..575ec1fb4a 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -59,6 +59,7 @@ import java.util.logging.Logger; import javax.annotation.CheckForNull; import static com.sun.jna.Pointer.NULL; +import hudson.SystemProperties; import static hudson.util.jna.GNUCLibrary.LIBC; import static java.util.logging.Level.FINE; import static java.util.logging.Level.FINER; @@ -1284,6 +1285,6 @@ public abstract class ProcessTree implements Iterable, IProcessTree, *

* This property supports two names for a compatibility reason. */ - public static boolean enabled = !Boolean.getBoolean(ProcessTreeKiller.class.getName()+".disable") - && !Boolean.getBoolean(ProcessTree.class.getName()+".disable"); + public static boolean enabled = !SystemProperties.getBoolean(ProcessTreeKiller.class.getName()+".disable") + && !SystemProperties.getBoolean(ProcessTree.class.getName()+".disable"); } diff --git a/core/src/main/java/hudson/util/RingBufferLogHandler.java b/core/src/main/java/hudson/util/RingBufferLogHandler.java index 469cdbba4b..d292123fad 100644 --- a/core/src/main/java/hudson/util/RingBufferLogHandler.java +++ b/core/src/main/java/hudson/util/RingBufferLogHandler.java @@ -23,6 +23,7 @@ */ package hudson.util; +import hudson.SystemProperties; import java.util.AbstractList; import java.util.List; import java.util.logging.Handler; @@ -35,7 +36,7 @@ import java.util.logging.LogRecord; */ public class RingBufferLogHandler extends Handler { - private static final int DEFAULT_RING_BUFFER_SIZE = Integer.getInteger(RingBufferLogHandler.class.getName() + ".defaultSize", 256); + private static final int DEFAULT_RING_BUFFER_SIZE = SystemProperties.getInteger(RingBufferLogHandler.class.getName() + ".defaultSize", 256); private int start = 0; private final LogRecord[] records; diff --git a/core/src/main/java/hudson/util/Secret.java b/core/src/main/java/hudson/util/Secret.java index 80be75b8ff..e0819149fc 100644 --- a/core/src/main/java/hudson/util/Secret.java +++ b/core/src/main/java/hudson/util/Secret.java @@ -29,6 +29,7 @@ import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.trilead.ssh2.crypto.Base64; +import hudson.SystemProperties; import jenkins.model.Jenkins; import hudson.Util; import jenkins.security.CryptoConfidentialKey; @@ -223,7 +224,7 @@ public final class Secret implements Serializable { * Workaround for JENKINS-6459 / http://java.net/jira/browse/GLASSFISH-11862 * @see #getCipher(String) */ - private static final String PROVIDER = System.getProperty(Secret.class.getName()+".provider"); + private static final String PROVIDER = SystemProperties.getProperty(Secret.class.getName()+".provider"); /** * For testing only. Override the secret key so that we can test this class without {@link Jenkins}. diff --git a/core/src/main/java/hudson/widgets/HistoryWidget.java b/core/src/main/java/hudson/widgets/HistoryWidget.java index 0059680ef5..695240a8d6 100644 --- a/core/src/main/java/hudson/widgets/HistoryWidget.java +++ b/core/src/main/java/hudson/widgets/HistoryWidget.java @@ -24,6 +24,7 @@ package hudson.widgets; import hudson.Functions; +import hudson.SystemProperties; import hudson.model.ModelObject; import hudson.model.Run; @@ -242,7 +243,7 @@ public class HistoryWidget extends Widget { req.getView(page,"ajaxBuildHistory.jelly").forward(req,rsp); } - static final int THRESHOLD = Integer.getInteger(HistoryWidget.class.getName()+".threshold",30); + static final int THRESHOLD = SystemProperties.getInteger(HistoryWidget.class.getName()+".threshold",30); public String getNextBuildNumberToFetch() { return nextBuildNumberToFetch; diff --git a/core/src/main/java/jenkins/InitReactorRunner.java b/core/src/main/java/jenkins/InitReactorRunner.java index f3b8711e32..364f5950d3 100644 --- a/core/src/main/java/jenkins/InitReactorRunner.java +++ b/core/src/main/java/jenkins/InitReactorRunner.java @@ -1,5 +1,6 @@ package jenkins; +import hudson.SystemProperties; import hudson.init.InitMilestone; import hudson.init.InitReactorListener; import hudson.util.DaemonThreadFactory; @@ -91,7 +92,7 @@ public class InitReactorRunner { protected void onInitMilestoneAttained(InitMilestone milestone) { } - private static final int TWICE_CPU_NUM = Integer.getInteger( + private static final int TWICE_CPU_NUM = SystemProperties.getInteger( InitReactorRunner.class.getName()+".concurrency", Runtime.getRuntime().availableProcessors() * 2); diff --git a/core/src/main/java/jenkins/model/Configuration.java b/core/src/main/java/jenkins/model/Configuration.java index 9de56f968c..97d6756165 100644 --- a/core/src/main/java/jenkins/model/Configuration.java +++ b/core/src/main/java/jenkins/model/Configuration.java @@ -23,6 +23,7 @@ */ package jenkins.model; +import hudson.SystemProperties; import hudson.model.Hudson; @@ -34,9 +35,9 @@ public class Configuration { } public static String getStringConfigParameter(String name, String defaultValue) { - String value = System.getProperty(Jenkins.class.getName()+"." + name); + String value = SystemProperties.getProperty(Jenkins.class.getName()+"." + name); if( value == null ) - value = System.getProperty(Hudson.class.getName()+"." + name); + value = SystemProperties.getProperty(Hudson.class.getName()+"." + name); return (value==null)?defaultValue:value; } } diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 942088b1c2..d375a13d67 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -50,6 +50,7 @@ import hudson.Plugin; import hudson.PluginManager; import hudson.PluginWrapper; import hudson.ProxyConfiguration; +import hudson.SystemProperties; import hudson.TcpSlaveAgentListener; import hudson.UDPBroadcastThread; import hudson.Util; @@ -4158,7 +4159,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve VERSION_HASH = Util.getDigestOf(ver).substring(0, 8); SESSION_HASH = Util.getDigestOf(ver+System.currentTimeMillis()).substring(0, 8); - if(ver.equals("?") || Boolean.getBoolean("hudson.script.noCache")) + if(ver.equals("?") || SystemProperties.getBoolean("hudson.script.noCache")) RESOURCE_PATH = ""; else RESOURCE_PATH = "/static/"+SESSION_HASH; diff --git a/core/src/main/java/jenkins/model/lazy/BuildReference.java b/core/src/main/java/jenkins/model/lazy/BuildReference.java index 93546d46e1..83a0d976b7 100644 --- a/core/src/main/java/jenkins/model/lazy/BuildReference.java +++ b/core/src/main/java/jenkins/model/lazy/BuildReference.java @@ -3,6 +3,7 @@ package jenkins.model.lazy; import hudson.Extension; import hudson.ExtensionList; import hudson.ExtensionPoint; +import hudson.SystemProperties; import hudson.model.Run; import java.lang.ref.Reference; import java.lang.ref.SoftReference; @@ -144,7 +145,7 @@ public final class BuildReference { @Extension(ordinal=Double.NEGATIVE_INFINITY) public static final class DefaultHolderFactory implements HolderFactory { public static final String MODE_PROPERTY = "jenkins.model.lazy.BuildReference.MODE"; - private static final String mode = System.getProperty(MODE_PROPERTY); + private static final String mode = SystemProperties.getProperty(MODE_PROPERTY); @Override public Holder make(R referent) { if (mode == null || mode.equals("soft")) { diff --git a/core/src/main/java/jenkins/security/ApiTokenProperty.java b/core/src/main/java/jenkins/security/ApiTokenProperty.java index 8aef388cbd..4e87c8b664 100644 --- a/core/src/main/java/jenkins/security/ApiTokenProperty.java +++ b/core/src/main/java/jenkins/security/ApiTokenProperty.java @@ -24,6 +24,7 @@ package jenkins.security; import hudson.Extension; +import hudson.SystemProperties; import hudson.Util; import hudson.model.Descriptor.FormException; import hudson.model.User; @@ -65,7 +66,7 @@ public class ApiTokenProperty extends UserProperty { * @since TODO */ private static final boolean SHOW_TOKEN_TO_ADMINS = - Boolean.getBoolean(ApiTokenProperty.class.getName() + ".showTokenToAdmins"); + SystemProperties.getBoolean(ApiTokenProperty.class.getName() + ".showTokenToAdmins"); @DataBoundConstructor diff --git a/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java b/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java index 3b41c006dd..a0feec091d 100644 --- a/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java +++ b/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java @@ -15,6 +15,7 @@ package jenkins.security; import hudson.Extension; +import hudson.SystemProperties; import jenkins.ExtensionFilter; import jenkins.model.Jenkins; import org.acegisecurity.Authentication; @@ -69,5 +70,5 @@ public class BasicHeaderRealPasswordAuthenticator extends BasicHeaderAuthenticat * Legacy property to disable the real password support. * Now that this is an extension, {@link ExtensionFilter} is a better way to control this. */ - public static boolean DISABLE = Boolean.getBoolean("jenkins.security.ignoreBasicAuth"); + public static boolean DISABLE = SystemProperties.getBoolean("jenkins.security.ignoreBasicAuth"); } diff --git a/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java b/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java index bc47e231b5..9155717606 100644 --- a/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java +++ b/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java @@ -1,6 +1,7 @@ package jenkins.security; import hudson.Extension; +import hudson.SystemProperties; import hudson.model.PageDecorator; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -13,5 +14,5 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; @Extension(ordinal = 1000) public class FrameOptionsPageDecorator extends PageDecorator { @Restricted(NoExternalUse.class) - public static boolean enabled = Boolean.valueOf(System.getProperty(FrameOptionsPageDecorator.class.getName() + ".enabled", "true")); + public static boolean enabled = Boolean.valueOf(SystemProperties.getProperty(FrameOptionsPageDecorator.class.getName() + ".enabled", "true")); } diff --git a/core/src/main/java/jenkins/security/SecureRequester.java b/core/src/main/java/jenkins/security/SecureRequester.java index 42c6ac1dbb..5443898928 100644 --- a/core/src/main/java/jenkins/security/SecureRequester.java +++ b/core/src/main/java/jenkins/security/SecureRequester.java @@ -2,6 +2,7 @@ package jenkins.security; import hudson.Extension; import hudson.ExtensionPoint; +import hudson.SystemProperties; import hudson.model.Api; import java.util.logging.Logger; import jenkins.model.Jenkins; @@ -34,7 +35,7 @@ public interface SecureRequester extends ExtensionPoint { @Extension class Default implements SecureRequester { private static final String PROP = "hudson.model.Api.INSECURE"; - private static final boolean INSECURE = Boolean.getBoolean(PROP); + private static final boolean INSECURE = SystemProperties.getBoolean(PROP); static { if (INSECURE) { Logger.getLogger(SecureRequester.class.getName()).warning(PROP + " system property is deprecated; implement SecureRequester instead"); diff --git a/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java b/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java index 706d17c0be..ab03d4ea16 100644 --- a/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java +++ b/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java @@ -1,6 +1,7 @@ package jenkins.security.s2m; import hudson.Extension; +import hudson.SystemProperties; import hudson.remoting.Callable; import hudson.remoting.ChannelBuilder; import jenkins.security.ChannelConfigurator; @@ -38,7 +39,7 @@ public class CallableDirectionChecker extends RoleChecker { * This is an escape hatch in case the fix breaks something critical, to allow the user * to keep operation. */ - public static boolean BYPASS = Boolean.getBoolean(BYPASS_PROP); + public static boolean BYPASS = SystemProperties.getBoolean(BYPASS_PROP); private CallableDirectionChecker(Object context) { this.context = context; diff --git a/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java b/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java index 563d19269e..c4a810fe9b 100644 --- a/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java +++ b/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java @@ -25,6 +25,7 @@ package jenkins.security.s2m; import hudson.Extension; +import hudson.SystemProperties; import hudson.remoting.ChannelBuilder; import jenkins.ReflectiveFilePathFilter; import jenkins.security.ChannelConfigurator; @@ -44,7 +45,7 @@ import java.util.logging.Logger; /** * Escape hatch to disable this check completely. */ - public static boolean BYPASS = Boolean.getBoolean(DefaultFilePathFilter.class.getName()+".allow"); + public static boolean BYPASS = SystemProperties.getBoolean(DefaultFilePathFilter.class.getName()+".allow"); private static final Logger LOGGER = Logger.getLogger(DefaultFilePathFilter.class.getName()); diff --git a/core/src/main/java/jenkins/slaves/NioChannelSelector.java b/core/src/main/java/jenkins/slaves/NioChannelSelector.java index 3aea28a1e3..97d97b4fbd 100644 --- a/core/src/main/java/jenkins/slaves/NioChannelSelector.java +++ b/core/src/main/java/jenkins/slaves/NioChannelSelector.java @@ -1,6 +1,7 @@ package jenkins.slaves; import hudson.Extension; +import hudson.SystemProperties; import hudson.model.Computer; import org.jenkinsci.remoting.nio.NioChannelHub; @@ -37,7 +38,7 @@ public class NioChannelSelector { /** * Escape hatch to disable use of NIO. */ - public static boolean DISABLED = Boolean.getBoolean(NioChannelSelector.class.getName()+".disabled"); + public static boolean DISABLED = SystemProperties.getBoolean(NioChannelSelector.class.getName()+".disabled"); private static final Logger LOGGER = Logger.getLogger(NioChannelSelector.class.getName()); } diff --git a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java index 794fc8626d..82efe25384 100644 --- a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java +++ b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java @@ -2,6 +2,7 @@ package jenkins.slaves; import hudson.Extension; import hudson.FilePath; +import hudson.SystemProperties; import hudson.model.Computer; import hudson.model.TaskListener; import hudson.remoting.Channel; @@ -74,5 +75,5 @@ public class StandardOutputSwapper extends ComputerListener { } private static final Logger LOGGER = Logger.getLogger(StandardOutputSwapper.class.getName()); - public static boolean disabled = Boolean.getBoolean(StandardOutputSwapper.class.getName()+".disabled"); + public static boolean disabled = SystemProperties.getBoolean(StandardOutputSwapper.class.getName()+".disabled"); } diff --git a/core/src/main/java/jenkins/util/xml/XMLUtils.java b/core/src/main/java/jenkins/util/xml/XMLUtils.java index 84e6f6151b..afe3bc844c 100644 --- a/core/src/main/java/jenkins/util/xml/XMLUtils.java +++ b/core/src/main/java/jenkins/util/xml/XMLUtils.java @@ -1,5 +1,6 @@ package jenkins.util.xml; +import hudson.SystemProperties; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.xml.sax.InputSource; @@ -66,7 +67,7 @@ public final class XMLUtils { // for some reason we could not convert source // this applies to DOMSource and StAXSource - and possibly 3rd party implementations... // a DOMSource can already be compromised as it is parsed by the time it gets to us. - if (Boolean.getBoolean(DISABLED_PROPERTY_NAME)) { + if (SystemProperties.getBoolean(DISABLED_PROPERTY_NAME)) { LOGGER.log(Level.WARNING, "XML external entity (XXE) prevention has been disabled by the system " + "property {0}=true Your system may be vulnerable to XXE attacks.", DISABLED_PROPERTY_NAME); if (LOGGER.isLoggable(Level.FINE)) {