From 46c0b4f9eee8eca2ab82fc3bd8d302e2962a17e6 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 5 Dec 2021 09:09:26 -0800 Subject: [PATCH] Break lines at 240 columns (#6013) --- .../java/hudson/cli/DisablePluginCommand.java | 10 ++- core/src/main/java/hudson/model/Computer.java | 57 +++++++++++-- core/src/main/java/hudson/model/Executor.java | 10 ++- .../main/java/hudson/model/Fingerprint.java | 14 +++- core/src/main/java/hudson/model/Item.java | 82 ++++++++++++++++--- .../src/main/java/hudson/model/ItemGroup.java | 3 +- .../java/hudson/model/ItemGroupMixIn.java | 8 +- .../java/hudson/model/ManagementLink.java | 4 +- core/src/main/java/hudson/model/Run.java | 3 +- core/src/main/java/hudson/scm/SCM.java | 40 ++++++++- .../main/java/hudson/slaves/DumbSlave.java | 12 ++- core/src/main/java/jenkins/model/Jenkins.java | 14 +++- .../jenkins/model/ParameterizedJobMixIn.java | 4 +- .../jenkins/model/lazy/LazyBuildMixIn.java | 3 +- .../jenkins/slaves/JnlpAgentReceiver.java | 4 +- core/src/main/java/jenkins/util/Timer.java | 4 +- .../java/jenkins/websocket/WebSockets.java | 7 +- ...ractUserDetailsAuthenticationProvider.java | 13 ++- .../hudson/slaves/ComputerLauncherTest.java | 28 ++++++- .../test/java/hudson/util/XStream2Test.java | 8 +- pom.xml | 2 +- .../security/ExtendedReadPermissionTest.java | 5 +- .../hudson/tools/InstallerTranslatorTest.java | 16 +++- test/src/test/java/lib/form/PasswordTest.java | 3 +- 24 files changed, 306 insertions(+), 48 deletions(-) diff --git a/core/src/main/java/hudson/cli/DisablePluginCommand.java b/core/src/main/java/hudson/cli/DisablePluginCommand.java index 59a1402a89..79d3a09f82 100644 --- a/core/src/main/java/hudson/cli/DisablePluginCommand.java +++ b/core/src/main/java/hudson/cli/DisablePluginCommand.java @@ -82,7 +82,15 @@ public class DisablePluginCommand extends CLICommand { try { strategyToUse = PluginWrapper.PluginDisableStrategy.valueOf(strategy.toUpperCase()); } catch (IllegalArgumentException iae) { - throw new IllegalArgumentException(hudson.cli.Messages.DisablePluginCommand_NoSuchStrategy(strategy, String.format("%s, %s, %s", PluginWrapper.PluginDisableStrategy.NONE, PluginWrapper.PluginDisableStrategy.MANDATORY, PluginWrapper.PluginDisableStrategy.ALL)), iae); + throw new IllegalArgumentException( + hudson.cli.Messages.DisablePluginCommand_NoSuchStrategy( + strategy, + String.format( + "%s, %s, %s", + PluginWrapper.PluginDisableStrategy.NONE, + PluginWrapper.PluginDisableStrategy.MANDATORY, + PluginWrapper.PluginDisableStrategy.ALL)), + iae); } // disable... diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index cbcdb99cd3..348b43423e 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -1787,16 +1787,59 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces } public static final PermissionGroup PERMISSIONS = new PermissionGroup(Computer.class,Messages._Computer_Permissions_Title()); - public static final Permission CONFIGURE = new Permission(PERMISSIONS,"Configure", Messages._Computer_ConfigurePermission_Description(), Permission.CONFIGURE, PermissionScope.COMPUTER); + public static final Permission CONFIGURE = + new Permission( + PERMISSIONS, + "Configure", + Messages._Computer_ConfigurePermission_Description(), + Permission.CONFIGURE, + PermissionScope.COMPUTER); /** * @since 1.532 */ - 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.JENKINS); - public static final Permission DISCONNECT = new Permission(PERMISSIONS,"Disconnect", Messages._Computer_DisconnectPermission_Description(), Jenkins.ADMINISTER, PermissionScope.COMPUTER); - public static final Permission CONNECT = new Permission(PERMISSIONS,"Connect", Messages._Computer_ConnectPermission_Description(), DISCONNECT, PermissionScope.COMPUTER); - public static final Permission BUILD = new Permission(PERMISSIONS, "Build", Messages._Computer_BuildPermission_Description(), Permission.WRITE, 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.JENKINS); + public static final Permission DISCONNECT = + new Permission( + PERMISSIONS, + "Disconnect", + Messages._Computer_DisconnectPermission_Description(), + Jenkins.ADMINISTER, + PermissionScope.COMPUTER); + public static final Permission CONNECT = + new Permission( + PERMISSIONS, + "Connect", + Messages._Computer_ConnectPermission_Description(), + DISCONNECT, + PermissionScope.COMPUTER); + public static final Permission BUILD = + new Permission( + PERMISSIONS, + "Build", + Messages._Computer_BuildPermission_Description(), + Permission.WRITE, + PermissionScope.COMPUTER); @Restricted(NoExternalUse.class) // called by jelly public static final Permission[] EXTENDED_READ_AND_CONNECT = diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index 556f88d8e8..f3e971f990 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -409,7 +409,15 @@ public class Executor extends Thread implements ModelObject { if (executable instanceof Actionable) { if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.log(FINER, "when running {0} from {1} we are copying {2} actions whereas the item currently has {3}", new Object[] {executable, workUnit.context.item, workUnit.context.actions, workUnit.context.item.getAllActions()}); + LOGGER.log( + FINER, + "when running {0} from {1} we are copying {2} actions whereas the item currently has {3}", + new Object[] { + executable, + workUnit.context.item, + workUnit.context.actions, + workUnit.context.item.getAllActions(), + }); } for (Action action: workUnit.context.actions) { ((Actionable) executable).addAction(action); diff --git a/core/src/main/java/hudson/model/Fingerprint.java b/core/src/main/java/hudson/model/Fingerprint.java index 2020c4841b..3d49b1977b 100644 --- a/core/src/main/java/hudson/model/Fingerprint.java +++ b/core/src/main/java/hudson/model/Fingerprint.java @@ -1416,7 +1416,19 @@ public class Fingerprint implements ModelObject, Saveable { } @Override public String toString() { - return "Fingerprint[original=" + original + ",hash=" + getHashString() + ",fileName=" + fileName + ",timestamp=" + DATE_CONVERTER.toString(timestamp) + ",usages=" + (usages == null ? "null" : new TreeMap<>(getUsages())) + ",facets=" + facets + "]"; + return "Fingerprint[original=" + + original + + ",hash=" + + getHashString() + + ",fileName=" + + fileName + + ",timestamp=" + + DATE_CONVERTER.toString(timestamp) + + ",usages=" + + (usages == null ? "null" : new TreeMap<>(getUsages())) + + ",facets=" + + facets + + "]"; } /** diff --git a/core/src/main/java/hudson/model/Item.java b/core/src/main/java/hudson/model/Item.java index 05cab87676..445c839984 100644 --- a/core/src/main/java/hudson/model/Item.java +++ b/core/src/main/java/hudson/model/Item.java @@ -249,20 +249,82 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont void delete() throws IOException, InterruptedException; PermissionGroup PERMISSIONS = new PermissionGroup(Item.class,Messages._Item_Permissions_Title()); - Permission CREATE = new Permission(PERMISSIONS, "Create", Messages._Item_CREATE_description(), Permission.CREATE, PermissionScope.ITEM_GROUP); - Permission DELETE = new Permission(PERMISSIONS, "Delete", Messages._Item_DELETE_description(), Permission.DELETE, PermissionScope.ITEM); - 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 CREATE = + new Permission( + PERMISSIONS, + "Create", + Messages._Item_CREATE_description(), + Permission.CREATE, + PermissionScope.ITEM_GROUP); + Permission DELETE = + new Permission( + PERMISSIONS, + "Delete", + Messages._Item_DELETE_description(), + Permission.DELETE, + PermissionScope.ITEM); + 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); /** * Ability to view configuration details. * If the user lacks {@link #CONFIGURE} then any {@link Secret}s must be masked out, even in encrypted form. * @see Secret#ENCRYPTED_VALUE_PATTERN */ - Permission EXTENDED_READ = new Permission(PERMISSIONS,"ExtendedRead", Messages._AbstractProject_ExtendedReadPermission_Description(), CONFIGURE, SystemProperties.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); - Permission WIPEOUT = new Permission(PERMISSIONS, "WipeOut", Messages._AbstractProject_WipeOutPermission_Description(), null, Functions.isWipeOutPermissionEnabled(), new PermissionScope[]{PermissionScope.ITEM}); - Permission CANCEL = new Permission(PERMISSIONS, "Cancel", Messages._AbstractProject_CancelPermission_Description(), Permission.UPDATE, PermissionScope.ITEM); + 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); + Permission WIPEOUT = + new Permission( + PERMISSIONS, + "WipeOut", + Messages._AbstractProject_WipeOutPermission_Description(), + null, + Functions.isWipeOutPermissionEnabled(), + new PermissionScope[] {PermissionScope.ITEM}); + Permission CANCEL = + new Permission( + PERMISSIONS, + "Cancel", + Messages._AbstractProject_CancelPermission_Description(), + Permission.UPDATE, + PermissionScope.ITEM); } diff --git a/core/src/main/java/hudson/model/ItemGroup.java b/core/src/main/java/hudson/model/ItemGroup.java index 72eea58438..61989b1711 100644 --- a/core/src/main/java/hudson/model/ItemGroup.java +++ b/core/src/main/java/hudson/model/ItemGroup.java @@ -99,7 +99,8 @@ public interface ItemGroup extends PersistenceRoot, ModelObject /** * Gets the {@link Item} inside this group that has a given name, or null if it does not exist. - * @return an item whose {@link Item#getName} is {@code name} and whose {@link Item#getParent} is {@code this}, or null if there is no such item, or there is but the current user lacks both {@link Item#DISCOVER} and {@link Item#READ} on it + * @return an item whose {@link Item#getName} is {@code name} and whose {@link Item#getParent} is {@code this}, + * or null if there is no such item, or there is but the current user lacks both {@link Item#DISCOVER} and {@link Item#READ} on it * @throws AccessDeniedException if the current user has {@link Item#DISCOVER} but not {@link Item#READ} on this item */ @CheckForNull T getItem(String name) throws AccessDeniedException; diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 7c973d29c7..06b914b65d 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -219,7 +219,13 @@ public abstract class ItemGroupMixIn { while (matcher.find()) { if (Secret.decrypt(matcher.group(1)) != null) { // AccessDeniedException2 does not permit a custom message, and anyway redirecting the user to the login screen is obviously pointless. - throw new AccessDeniedException(Messages.ItemGroupMixIn_may_not_copy_as_it_contains_secrets_and_(src.getFullName(), Jenkins.getAuthentication2().getName(), Item.PERMISSIONS.title, Item.EXTENDED_READ.name, Item.CONFIGURE.name)); + throw new AccessDeniedException( + Messages.ItemGroupMixIn_may_not_copy_as_it_contains_secrets_and_( + src.getFullName(), + Jenkins.getAuthentication2().getName(), + Item.PERMISSIONS.title, + Item.EXTENDED_READ.name, + Item.CONFIGURE.name)); } } } diff --git a/core/src/main/java/hudson/model/ManagementLink.java b/core/src/main/java/hudson/model/ManagementLink.java index 32293017c7..86a8cd6195 100644 --- a/core/src/main/java/hudson/model/ManagementLink.java +++ b/core/src/main/java/hudson/model/ManagementLink.java @@ -188,7 +188,9 @@ public abstract class ManagementLink implements ExtensionPoint, Action { */ TROUBLESHOOTING(Messages._ManagementLink_Category_TROUBLESHOOTING()), /** - * Tools are specifically tools for administrators, such as the Jenkins CLI and Script Console, as well as specific stand-alone administrative features ({@link jenkins.management.ShutdownLink}, {@link jenkins.management.ReloadLink}). + * Tools are specifically tools for administrators, + * such as the Jenkins CLI and Script Console, + * as well as specific stand-alone administrative features ({@link jenkins.management.ShutdownLink}, {@link jenkins.management.ReloadLink}). * This has nothing to do with build tools or tool installers. */ TOOLS(Messages._ManagementLink_Category_TOOLS()), diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 37836a9c4c..c573381488 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -1464,7 +1464,8 @@ public abstract class Run ,RunT extends Run, ExtensionPoint { * this exception should be simply propagated all the way up. * @since 1.568 */ - public PollingResult compareRemoteRevisionWith(@NonNull Job project, @Nullable Launcher launcher, @Nullable FilePath workspace, @NonNull TaskListener listener, @NonNull SCMRevisionState baseline) throws IOException, InterruptedException { - if (project instanceof AbstractProject && Util.isOverridden(SCM.class, getClass(), "compareRemoteRevisionWith", AbstractProject.class, Launcher.class, FilePath.class, TaskListener.class, SCMRevisionState.class)) { + public PollingResult compareRemoteRevisionWith( + @NonNull Job project, + @Nullable Launcher launcher, + @Nullable FilePath workspace, + @NonNull TaskListener listener, + @NonNull SCMRevisionState baseline) + throws IOException, InterruptedException { + if (project instanceof AbstractProject + && Util.isOverridden( + SCM.class, + getClass(), + "compareRemoteRevisionWith", + AbstractProject.class, + Launcher.class, + FilePath.class, + TaskListener.class, + SCMRevisionState.class)) { return compareRemoteRevisionWith((AbstractProject) project, launcher, workspace, listener, baseline); } else { throw new AbstractMethodError("you must override the new overload of compareRemoteRevisionWith"); @@ -478,8 +493,25 @@ public abstract class SCM implements Describable, ExtensionPoint { * @throws AbortException in case of a routine failure * @since 1.568 */ - public void checkout(@NonNull Run build, @NonNull Launcher launcher, @NonNull FilePath workspace, @NonNull TaskListener listener, @CheckForNull File changelogFile, @CheckForNull SCMRevisionState baseline) throws IOException, InterruptedException { - if (build instanceof AbstractBuild && listener instanceof BuildListener && Util.isOverridden(SCM.class, getClass(), "checkout", AbstractBuild.class, Launcher.class, FilePath.class, BuildListener.class, File.class)) { + public void checkout( + @NonNull Run build, + @NonNull Launcher launcher, + @NonNull FilePath workspace, + @NonNull TaskListener listener, + @CheckForNull File changelogFile, + @CheckForNull SCMRevisionState baseline) + throws IOException, InterruptedException { + if (build instanceof AbstractBuild + && listener instanceof BuildListener + && Util.isOverridden( + SCM.class, + getClass(), + "checkout", + AbstractBuild.class, + Launcher.class, + FilePath.class, + BuildListener.class, + File.class)) { if (changelogFile == null) { changelogFile = File.createTempFile("changelog", ".xml"); try { diff --git a/core/src/main/java/hudson/slaves/DumbSlave.java b/core/src/main/java/hudson/slaves/DumbSlave.java index 5f5fef1c10..f8eb0dc456 100644 --- a/core/src/main/java/hudson/slaves/DumbSlave.java +++ b/core/src/main/java/hudson/slaves/DumbSlave.java @@ -55,7 +55,17 @@ public final class DumbSlave extends Slave { * Use {@link #DumbSlave(String, String, ComputerLauncher)} and configure the rest through setters. */ @Deprecated - public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List> nodeProperties) throws IOException, FormException { + public DumbSlave( + String name, + String nodeDescription, + String remoteFS, + String numExecutors, + Node.Mode mode, + String labelString, + ComputerLauncher launcher, + RetentionStrategy retentionStrategy, + List> nodeProperties) + throws IOException, FormException { super(name, nodeDescription, remoteFS, numExecutors, mode, labelString, launcher, retentionStrategy, nodeProperties); } diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index c6c680b516..2cb61b2272 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -5597,14 +5597,24 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve * * @since 2.266 */ - public static final Authentication ANONYMOUS2 = new AnonymousAuthenticationToken("anonymous", "anonymous", Collections.singleton(new SimpleGrantedAuthority("anonymous"))); + public static final Authentication ANONYMOUS2 = + new AnonymousAuthenticationToken( + "anonymous", + "anonymous", + Collections.singleton(new SimpleGrantedAuthority("anonymous"))); /** * @deprecated use {@link #ANONYMOUS2} * @since 1.343 */ @Deprecated - public static final org.acegisecurity.Authentication ANONYMOUS = new org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken("anonymous", "anonymous", new org.acegisecurity.GrantedAuthority[] {new org.acegisecurity.GrantedAuthorityImpl("anonymous")}); + public static final org.acegisecurity.Authentication ANONYMOUS = + new org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken( + "anonymous", + "anonymous", + new org.acegisecurity.GrantedAuthority[] { + new org.acegisecurity.GrantedAuthorityImpl("anonymous"), + }); static { try { diff --git a/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java b/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java index a5c2a27cda..0752b0bcc2 100644 --- a/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java +++ b/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java @@ -132,7 +132,9 @@ public abstract class ParameterizedJobMixIn & Param * @param job a job which might be schedulable * @param quietPeriod seconds to wait before starting; use {@code -1} to use the job’s default settings * @param actions various actions to associate with the scheduling, such as {@link ParametersAction} or {@link CauseAction} - * @return a newly created, or reused, queue item if the job could be scheduled; null if it was refused for some reason (e.g., some {@link Queue.QueueDecisionHandler} rejected it), or if {@code job} is not a {@link ParameterizedJob} or it is not {@link Job#isBuildable}) + * @return a newly created, or reused, queue item if the job could be scheduled; + * null if it was refused for some reason (e.g., some {@link Queue.QueueDecisionHandler} rejected it), + * or if {@code job} is not a {@link ParameterizedJob} or it is not {@link Job#isBuildable}) * @since 1.621 */ public static @CheckForNull Queue.Item scheduleBuild2(final Job job, int quietPeriod, Action... actions) { diff --git a/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java b/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java index 23cdb54603..adec27c4f2 100644 --- a/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java +++ b/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java @@ -268,7 +268,8 @@ public abstract class LazyBuildMixIn & Queue.Task & */ public interface LazyLoadingJob & Queue.Task & LazyBuildMixIn.LazyLoadingJob, RunT extends Run & LazyLoadingRun> { LazyBuildMixIn getLazyBuildMixIn(); - // not offering default implementation for _getRuns(), removeRun(R), getBuild(String), getBuildByNumber(int), getFirstBuild(), getLastBuild(), getNearestBuild(int), getNearestOldBuild(int), or createHistoryWidget() since they are defined in Job + // not offering default implementation for _getRuns(), removeRun(R), getBuild(String), getBuildByNumber(int), getFirstBuild(), getLastBuild(), getNearestBuild(int), getNearestOldBuild(int), or createHistoryWidget() + // since they are defined in Job // (could allow implementations to call LazyLoadingJob.super.theMethod()) } diff --git a/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java b/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java index fbea82b0d2..774e65c170 100644 --- a/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java +++ b/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java @@ -19,7 +19,9 @@ import org.jenkinsci.remoting.engine.JnlpConnectionStateListener; * for different purposes outside {@link Slave}s. *
    - *
  • When the {@link jenkins.slaves.JnlpAgentReceiver#exists(String)} method is invoked for an agent, the {@link jenkins.slaves.JnlpAgentReceiver#owns(String)} method is called on all the extension points: if no owner is found an exception is thrown.
  • + *
  • When the {@link jenkins.slaves.JnlpAgentReceiver#exists(String)} method is invoked for an agent, + * the {@link jenkins.slaves.JnlpAgentReceiver#owns(String)} method is called on all the extension points: + * if no owner is found an exception is thrown.
  • *
  • If owner is found, then the {@link org.jenkinsci.remoting.engine.JnlpConnectionState} lifecycle methods are invoked for all registered {@link JnlpConnectionStateListener} * until the one which changes the state of {@link org.jenkinsci.remoting.engine.JnlpConnectionState} by setting an approval or rejected state is found. * When found, that listener will be set as the owner of the incoming connection event.
  • diff --git a/core/src/main/java/jenkins/util/Timer.java b/core/src/main/java/jenkins/util/Timer.java index 4521312fd8..0b2ed74271 100644 --- a/core/src/main/java/jenkins/util/Timer.java +++ b/core/src/main/java/jenkins/util/Timer.java @@ -44,7 +44,9 @@ public class Timer { // corePoolSize is set to 10, but will only be created if needed. // ScheduledThreadPoolExecutor "acts as a fixed-sized pool using corePoolSize threads" // TODO consider also wrapping in ContextResettingExecutorService - executorService = new ImpersonatingScheduledExecutorService(new ErrorLoggingScheduledThreadPoolExecutor(10, new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()), "jenkins.util.Timer")), ACL.SYSTEM2); + executorService = new ImpersonatingScheduledExecutorService( + new ErrorLoggingScheduledThreadPoolExecutor(10, new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()), "jenkins.util.Timer")), + ACL.SYSTEM2); } return executorService; } diff --git a/core/src/main/java/jenkins/websocket/WebSockets.java b/core/src/main/java/jenkins/websocket/WebSockets.java index 5410fba7bb..91d80c8c5f 100644 --- a/core/src/main/java/jenkins/websocket/WebSockets.java +++ b/core/src/main/java/jenkins/websocket/WebSockets.java @@ -100,7 +100,12 @@ public class WebSockets { if (factory == null) { staticInit(); Class webSocketPolicyClass = cl.loadClass("org.eclipse.jetty.websocket.api.WebSocketPolicy"); - factory = cl.loadClass("org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader").getMethod("load", ServletContext.class, webSocketPolicyClass).invoke(null, Stapler.getCurrent().getServletContext(), webSocketPolicyClass.getMethod("newServerPolicy").invoke(null)); + factory = cl.loadClass("org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader") + .getMethod("load", ServletContext.class, webSocketPolicyClass) + .invoke( + null, + Stapler.getCurrent().getServletContext(), + webSocketPolicyClass.getMethod("newServerPolicy").invoke(null)); webSocketServletFactoryClass.getMethod("start").invoke(factory); Class webSocketCreatorClass = cl.loadClass("org.eclipse.jetty.websocket.servlet.WebSocketCreator"); webSocketServletFactoryClass.getMethod("setCreator", webSocketCreatorClass).invoke(factory, Proxy.newProxyInstance(cl, new Class[] {webSocketCreatorClass}, this::createWebSocket)); diff --git a/core/src/main/java/org/acegisecurity/providers/dao/AbstractUserDetailsAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/dao/AbstractUserDetailsAuthenticationProvider.java index 69720e7b4d..cb55421693 100644 --- a/core/src/main/java/org/acegisecurity/providers/dao/AbstractUserDetailsAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/dao/AbstractUserDetailsAuthenticationProvider.java @@ -37,9 +37,13 @@ import org.acegisecurity.userdetails.UserDetails; @Deprecated public abstract class AbstractUserDetailsAuthenticationProvider implements AuthenticationProvider { - private final org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider delegate = new org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider() { + private final org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider delegate = + new org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider() { @Override - protected void additionalAuthenticationChecks(org.springframework.security.core.userdetails.UserDetails userDetails, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) throws org.springframework.security.core.AuthenticationException { + protected void additionalAuthenticationChecks( + org.springframework.security.core.userdetails.UserDetails userDetails, + org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) + throws org.springframework.security.core.AuthenticationException { try { AbstractUserDetailsAuthenticationProvider.this.additionalAuthenticationChecks(UserDetails.fromSpring(userDetails), new UsernamePasswordAuthenticationToken(authentication)); } catch (AcegiSecurityException x) { @@ -47,7 +51,10 @@ public abstract class AbstractUserDetailsAuthenticationProvider implements Authe } } @Override - protected org.springframework.security.core.userdetails.UserDetails retrieveUser(String username, org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) throws org.springframework.security.core.AuthenticationException { + protected org.springframework.security.core.userdetails.UserDetails retrieveUser( + String username, + org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication) + throws org.springframework.security.core.AuthenticationException { try { return AbstractUserDetailsAuthenticationProvider.this.retrieveUser(username, new UsernamePasswordAuthenticationToken(authentication)).toSpring(); } catch (AcegiSecurityException x) { diff --git a/core/src/test/java/hudson/slaves/ComputerLauncherTest.java b/core/src/test/java/hudson/slaves/ComputerLauncherTest.java index 8bf73740da..6b93ec6430 100644 --- a/core/src/test/java/hudson/slaves/ComputerLauncherTest.java +++ b/core/src/test/java/hudson/slaves/ComputerLauncherTest.java @@ -39,15 +39,37 @@ import org.jvnet.hudson.test.Issue; public class ComputerLauncherTest { @Test public void jdk7() { - assertThrows(IOException.class, () -> assertChecked("java version \"1.7.0_05\"\nJava(TM) SE Runtime Environment (build 1.7.0_05-b05)\nJava HotSpot(TM) Server VM (build 23.1-b03, mixed mode)\n", "1.7.0")); + assertThrows( + IOException.class, + () -> + assertChecked( + "java version \"1.7.0_05\"\n" + + "Java(TM) SE Runtime Environment (build 1.7.0_05-b05)\n" + + "Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)\n", + "1.7.0")); } @Test public void openJDK7() { - assertThrows(IOException.class, () -> assertChecked("openjdk version \"1.7.0-internal\"\nOpenJDK Runtime Environment (build 1.7.0-internal-pkgsrc_2010_01_03_06_54-b00)\nOpenJDK 64-Bit Server VM (build 17.0-b04, mixed mode)\n", "1.7.0")); + assertThrows( + IOException.class, + () -> + assertChecked( + "openjdk version \"1.7.0-internal\"\n" + + "OpenJDK Runtime Environment (build" + + " 1.7.0-internal-pkgsrc_2010_01_03_06_54-b00)\n" + + "OpenJDK 64-Bit Server VM (build 17.0-b04, mixed mode)\n", + "1.7.0")); } @Test public void jdk6() { - assertThrows(IOException.class, () -> assertChecked("java version \"1.6.0_33\"\nJava(TM) SE Runtime Environment (build 1.6.0_33-b03)\nJava HotSpot(TM) Server VM (build 20.8-b03, mixed mode)\n", "1.6.0")); + assertThrows( + IOException.class, + () -> + assertChecked( + "java version \"1.6.0_33\"\n" + + "Java(TM) SE Runtime Environment (build 1.6.0_33-b03)\n" + + "Java HotSpot(TM) Server VM (build 20.8-b03, mixed mode)\n", + "1.6.0")); } @Test public void jdk5() { diff --git a/core/src/test/java/hudson/util/XStream2Test.java b/core/src/test/java/hudson/util/XStream2Test.java index 70d80879c3..efb8f8e2be 100644 --- a/core/src/test/java/hudson/util/XStream2Test.java +++ b/core/src/test/java/hudson/util/XStream2Test.java @@ -284,7 +284,13 @@ public class XStream2Test { @Issue("SECURITY-105") @Test public void dynamicProxyBlocked() { - assertThrows(XStreamException.class, () -> ((Runnable) new XStream2().fromXML("java.lang.Runnableoops")).run()); + assertThrows( + XStreamException.class, + () -> ((Runnable) new XStream2().fromXML( + "java.lang.Runnableoops")) + .run()); assertFalse("should never have run that", Hacked.tripped); } diff --git a/pom.xml b/pom.xml index 58622861cc..09f6650f29 100644 --- a/pom.xml +++ b/pom.xml @@ -409,7 +409,7 @@ THE SOFTWARE. - + diff --git a/test/src/test/java/hudson/security/ExtendedReadPermissionTest.java b/test/src/test/java/hudson/security/ExtendedReadPermissionTest.java index b385e0834d..5a3b154a7f 100644 --- a/test/src/test/java/hudson/security/ExtendedReadPermissionTest.java +++ b/test/src/test/java/hudson/security/ExtendedReadPermissionTest.java @@ -62,7 +62,10 @@ public class ExtendedReadPermissionTest { assertNull(saveButton); } - @Ignore("This was actually testing a design of matrix-auth rather than core: that permissions, though formerly granted, are ignored if currently disabled. Permission.enabled Javadoc only discusses visibility. MockAuthorizationStrategy does not implement this check.") + @Ignore( + "This was actually testing a design of matrix-auth rather than core: that permissions, though formerly granted, are ignored if currently disabled." + + " Permission.enabled Javadoc only discusses visibility." + + " MockAuthorizationStrategy does not implement this check.") @Test public void readOnlyConfigAccessWithPermissionDisabled() throws Exception { setPermissionEnabled(false); diff --git a/test/src/test/java/hudson/tools/InstallerTranslatorTest.java b/test/src/test/java/hudson/tools/InstallerTranslatorTest.java index e2c5448818..4f30524f52 100644 --- a/test/src/test/java/hudson/tools/InstallerTranslatorTest.java +++ b/test/src/test/java/hudson/tools/InstallerTranslatorTest.java @@ -71,8 +71,20 @@ public class InstallerTranslatorTest { String jdk2Path = Functions.isWindows() ? "C:\\jdk2" : "/opt/jdk2"; Node slave1 = r.createSlave(); Node slave2 = r.createSlave(); - JDK jdk1 = new JDK("jdk1", null, Collections.singletonList(new InstallSourceProperty(Collections.singletonList(Functions.isWindows() ? new BatchCommandInstaller(null, "echo installed jdk1", jdk1Path) : new CommandInstaller(null, "echo installed jdk1", jdk1Path))))); - JDK jdk2 = new JDK("jdk2", null, Collections.singletonList(new InstallSourceProperty(Collections.singletonList(Functions.isWindows() ? new BatchCommandInstaller(null, "echo installed jdk2", jdk2Path) : new CommandInstaller(null, "echo installed jdk2", jdk2Path))))); + JDK jdk1 = new JDK( + "jdk1", + null, + Collections.singletonList(new InstallSourceProperty(Collections.singletonList( + Functions.isWindows() + ? new BatchCommandInstaller(null, "echo installed jdk1", jdk1Path) + : new CommandInstaller(null, "echo installed jdk1", jdk1Path))))); + JDK jdk2 = new JDK( + "jdk2", + null, + Collections.singletonList(new InstallSourceProperty(Collections.singletonList( + Functions.isWindows() + ? new BatchCommandInstaller(null, "echo installed jdk2", jdk2Path) + : new CommandInstaller(null, "echo installed jdk2", jdk2Path))))); r.jenkins.getJDKs().add(jdk1); r.jenkins.getJDKs().add(jdk2); FreeStyleProject p = r.createFreeStyleProject(); diff --git a/test/src/test/java/lib/form/PasswordTest.java b/test/src/test/java/lib/form/PasswordTest.java index 59989a06b5..61553e17ec 100644 --- a/test/src/test/java/lib/form/PasswordTest.java +++ b/test/src/test/java/lib/form/PasswordTest.java @@ -421,7 +421,8 @@ public class PasswordTest { // confirm the Secret getter/setter will not change encrypted value (keeps IV) assertEquals(secretWithSecretGetterSecretSetter.getEncryptedValue(), buildStep.secretWithSecretGetterSecretSetter.getEncryptedValue()); - // This depends on implementation; if the Getter returns the plain text (to be re-encrypted by Functions#getPasswordValue), then this won't work, but if they getter returns #getEncrytedValue (as implemented in the build step here), it does + // This depends on implementation; if the Getter returns the plain text (to be re-encrypted by Functions#getPasswordValue), then this won't work, + // but if the getter returns #getEncrytedValue (as implemented in the build step here), it does. // While clever, would recommend fixing mismatched getters/setters here assertEquals(secretWithStringGetterSecretSetter.getEncryptedValue(), buildStep.secretWithStringGetterSecretSetter.getEncryptedValue());