diff --git a/cli/src/main/java/hudson/cli/CLI.java b/cli/src/main/java/hudson/cli/CLI.java index 910331b3ee..988e9f1635 100644 --- a/cli/src/main/java/hudson/cli/CLI.java +++ b/cli/src/main/java/hudson/cli/CLI.java @@ -343,17 +343,20 @@ public class CLI { class Authenticator extends ClientEndpointConfig.Configurator { HandshakeResponse hr; + @Override public void beforeRequest(Map> headers) { if (factory.authorization != null) { headers.put("Authorization", List.of(factory.authorization)); } } + @Override public void afterResponse(HandshakeResponse hr) { this.hr = hr; } } + var authenticator = new Authenticator(); ClientManager client = ClientManager.createClient(JdkClientContainer.class.getName()); // ~ ContainerProvider.getWebSocketContainer() diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 3d6edf832f..fd257fdb33 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -279,7 +279,7 @@ public class ClassicPluginStrategy implements PluginStrategy { /** * @deprecated since 2.459 use {@link #createClassLoader(String, List, ClassLoader, Attributes)} */ - @Deprecated(since="2.459") + @Deprecated(since = "2.459") protected ClassLoader createClassLoader(List paths, ClassLoader parent, Attributes atts) throws IOException { // generate a legacy id so at least we can track to something return createClassLoader("unidentified-" + UUID.randomUUID(), paths, parent, atts); diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index 195671b1b4..6e6bfc9dad 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -1115,7 +1115,21 @@ public abstract class Launcher { final String workDir = psPwd == null ? null : psPwd.getRemote(); try { - RemoteLaunchCallable remote = new RemoteLaunchCallable(ps.commands, ps.masks, ps.envs, in, ps.reverseStdin, out, ps.reverseStdout, err, ps.reverseStderr, ps.quiet, workDir, listener, ps.stdoutListener, envVarsFilterRuleWrapper); + RemoteLaunchCallable remote = new RemoteLaunchCallable( + ps.commands, + ps.masks, + ps.envs, + in, + ps.reverseStdin, + out, + ps.reverseStdout, + err, + ps.reverseStderr, + ps.quiet, + workDir, + listener, + ps.stdoutListener, + envVarsFilterRuleWrapper); // reset the rules to prevent build step without rules configuration to re-use those envVarsFilterRuleWrapper = null; return new ProcImpl(getChannel().call(remote)); diff --git a/core/src/main/java/hudson/model/ComputerSet.java b/core/src/main/java/hudson/model/ComputerSet.java index fcc0aa4e41..cb8d19b78a 100644 --- a/core/src/main/java/hudson/model/ComputerSet.java +++ b/core/src/main/java/hudson/model/ComputerSet.java @@ -115,8 +115,8 @@ public final class ComputerSet extends AbstractModelObject implements Describabl } /** - * @deprecated Use {@link #getComputers()} instead. * @return All {@link Computer} instances managed by this set. + * @deprecated Use {@link #getComputers()} instead. */ @Deprecated(since = "2.480") public Computer[] get_all() { diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 1bbf3dad1a..2392c66aee 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -354,10 +354,12 @@ public abstract class Job, RunT extends Run job, SaveNextBuildNumber saveNextBuildNumber) throws IOException; + /** * Provides an externally accessible alias for {@link Job#saveNextBuildNumber}, which is {@code protected}. * ({@link #getNextBuildNumber} and {@link #fastUpdateNextBuildNumber} are already accessible.) */ + interface SaveNextBuildNumber { void call() throws IOException; } diff --git a/core/src/main/java/hudson/model/UserPropertyDescriptor.java b/core/src/main/java/hudson/model/UserPropertyDescriptor.java index f19a54e14a..542f0a4ccd 100644 --- a/core/src/main/java/hudson/model/UserPropertyDescriptor.java +++ b/core/src/main/java/hudson/model/UserPropertyDescriptor.java @@ -117,11 +117,9 @@ public abstract class UserPropertyDescriptor extends Descriptor { * Method proposed to prevent plugins to rely on too recent core version * while keeping the possibility to use the categories. * - * @deprecated This should only be used when the core requirement is below the version this method was added - * * @return String name corresponding to the symbol of {@link #getUserPropertyCategory()} - * * @since 2.468 + * @deprecated This should only be used when the core requirement is below the version this method was added */ @Deprecated protected @CheckForNull String getUserPropertyCategoryAsString() { diff --git a/core/src/main/java/hudson/model/userproperty/UserPropertyCategory.java b/core/src/main/java/hudson/model/userproperty/UserPropertyCategory.java index 5d5467b6ee..1d370e3e3b 100644 --- a/core/src/main/java/hudson/model/userproperty/UserPropertyCategory.java +++ b/core/src/main/java/hudson/model/userproperty/UserPropertyCategory.java @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package hudson.model.userproperty; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAccountAction.java b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAccountAction.java index c0424e8284..79c8a0e955 100644 --- a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAccountAction.java +++ b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAccountAction.java @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package hudson.model.userproperty; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAppearanceAction.java b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAppearanceAction.java index 88d08a8add..d4a5ebc2ce 100644 --- a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAppearanceAction.java +++ b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryAppearanceAction.java @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package hudson.model.userproperty; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryExperimentalAction.java b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryExperimentalAction.java index bb242bacad..93d6593fc6 100644 --- a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryExperimentalAction.java +++ b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryExperimentalAction.java @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package hudson.model.userproperty; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryPreferencesAction.java b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryPreferencesAction.java index 7a74b702e6..83e14ce9b3 100644 --- a/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryPreferencesAction.java +++ b/core/src/main/java/hudson/model/userproperty/UserPropertyCategoryPreferencesAction.java @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package hudson.model.userproperty; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/hudson/model/userproperty/UserPropertyCategorySecurityAction.java b/core/src/main/java/hudson/model/userproperty/UserPropertyCategorySecurityAction.java index a6cb3e6ed3..03513b37aa 100644 --- a/core/src/main/java/hudson/model/userproperty/UserPropertyCategorySecurityAction.java +++ b/core/src/main/java/hudson/model/userproperty/UserPropertyCategorySecurityAction.java @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package hudson.model.userproperty; +package hudson.model.userproperty; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; diff --git a/core/src/main/java/hudson/util/RobustReflectionConverter.java b/core/src/main/java/hudson/util/RobustReflectionConverter.java index 686aad13c3..5267692252 100644 --- a/core/src/main/java/hudson/util/RobustReflectionConverter.java +++ b/core/src/main/java/hudson/util/RobustReflectionConverter.java @@ -464,7 +464,14 @@ public class RobustReflectionConverter implements Converter { return context.convertAnother(result, type, converter); } - private void writeValueToImplicitCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Object value, Map> implicitCollections, Map> implicitCollectionElementTypes, Object result, String itemFieldName) { + private void writeValueToImplicitCollection( + HierarchicalStreamReader reader, + UnmarshallingContext context, + Object value, + Map> implicitCollections, + Map> implicitCollectionElementTypes, + Object result, + String itemFieldName) { String fieldName = mapper.getFieldNameForItemTypeAndName(context.getRequiredType(), value.getClass(), itemFieldName); if (fieldName != null) { Collection collection = implicitCollections.get(fieldName); diff --git a/core/src/main/java/jenkins/agents/IOfflineCause.java b/core/src/main/java/jenkins/agents/IOfflineCause.java index b1c32820e8..ffc8dfdfd8 100644 --- a/core/src/main/java/jenkins/agents/IOfflineCause.java +++ b/core/src/main/java/jenkins/agents/IOfflineCause.java @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package jenkins.agents; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/core/src/main/java/jenkins/model/IComputer.java b/core/src/main/java/jenkins/model/IComputer.java index e00ee78bd3..ad4c5aa8ca 100644 --- a/core/src/main/java/jenkins/model/IComputer.java +++ b/core/src/main/java/jenkins/model/IComputer.java @@ -185,6 +185,7 @@ public interface IComputer extends AccessControlled, IconSpec { * Returns the number of {@link IExecutor}s that are doing some work right now. */ int countBusy(); + /** * Returns the current size of the executor pool for this computer. */ @@ -194,6 +195,7 @@ public interface IComputer extends AccessControlled, IconSpec { * @return true if the computer is online. */ boolean isOnline(); + /** * @return the number of {@link IExecutor}s that are idle right now. */ diff --git a/core/src/main/java/jenkins/model/Nodes.java b/core/src/main/java/jenkins/model/Nodes.java index ae78028c2d..e4cf934fd7 100644 --- a/core/src/main/java/jenkins/model/Nodes.java +++ b/core/src/main/java/jenkins/model/Nodes.java @@ -113,7 +113,7 @@ public class Nodes implements PersistenceRoot { * @throws IOException if the new list of nodes could not be persisted. */ public void setNodes(final @NonNull Collection nodes) throws IOException { - Map toRemove = new HashMap<>(); + Map toRemove = new HashMap<>(); Queue.withLock(() -> { toRemove.putAll(Nodes.this.nodes); for (var node : nodes) { diff --git a/core/src/main/java/jenkins/security/s2m/JarURLValidatorImpl.java b/core/src/main/java/jenkins/security/s2m/JarURLValidatorImpl.java index 7fafcea946..24a7dc64a6 100644 --- a/core/src/main/java/jenkins/security/s2m/JarURLValidatorImpl.java +++ b/core/src/main/java/jenkins/security/s2m/JarURLValidatorImpl.java @@ -78,6 +78,7 @@ public class JarURLValidatorImpl extends ChannelConfigurator implements JarURLVa LOGGER.log(Level.FINE, () -> "Allowing URL: " + url); } } + @SuppressFBWarnings( value = "DMI_COLLECTION_OF_URLS", justification = "All URLs point to local files, so no DNS lookup.") diff --git a/core/src/test/java/jenkins/monitor/OperatingSystemEndOfLifeAdminMonitorTest.java b/core/src/test/java/jenkins/monitor/OperatingSystemEndOfLifeAdminMonitorTest.java index 38a4531613..42fd7f39fd 100644 --- a/core/src/test/java/jenkins/monitor/OperatingSystemEndOfLifeAdminMonitorTest.java +++ b/core/src/test/java/jenkins/monitor/OperatingSystemEndOfLifeAdminMonitorTest.java @@ -197,7 +197,7 @@ public class OperatingSystemEndOfLifeAdminMonitorTest { * name, and expected value for each of the resource files used by * the test. * - * @param simplifyExpectedValue if true, then the expected value + * @param simplify if true, then the expected value * is simplified by replacing ' ' with '-', by replacing '/' with * '-', and by removing '(' and ')'. * @return arguments for ParameterizedTest, resource file name, diff --git a/pom.xml b/pom.xml index 92f41a4e88..6b6707ba1e 100644 --- a/pom.xml +++ b/pom.xml @@ -375,6 +375,11 @@ THE SOFTWARE. + + org.apache.maven.plugins + maven-checkstyle-plugin + + diff --git a/test/src/test/java/hudson/model/UserPropertyTest.java b/test/src/test/java/hudson/model/UserPropertyTest.java index 91c977d4ec..b19e068cbf 100644 --- a/test/src/test/java/hudson/model/UserPropertyTest.java +++ b/test/src/test/java/hudson/model/UserPropertyTest.java @@ -37,7 +37,7 @@ public class UserPropertyTest { public JenkinsRule j = new JenkinsRule(); public User configRoundtrip(User u) throws Exception { - submit(j.createWebClient().goTo(u.getUrl()+"/account/").getFormByName("config")); + submit(j.createWebClient().goTo(u.getUrl() + "/account/").getFormByName("config")); return u; } diff --git a/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java b/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java index b9f0449b72..f24e291f92 100644 --- a/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java +++ b/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java @@ -164,7 +164,7 @@ public class HudsonPrivateSecurityRealmFIPSTest { User u1 = securityRealm.createAccount("test", "aValidFipsPass"); WebClient wc = j.createWebClient(); - wc.login("test","aValidFipsPass"); + wc.login("test", "aValidFipsPass"); HtmlPage configurePage = wc.goTo(u1.getUrl() + "/security/"); HtmlPasswordInput password1 = configurePage.getElementByName("user.password"); @@ -192,7 +192,7 @@ public class HudsonPrivateSecurityRealmFIPSTest { WebClient wc = j.createWebClient(); - wc.login("test","aValidFipsPass"); + wc.login("test", "aValidFipsPass"); HtmlPage configurePage = wc.goTo(u1.getUrl() + "/security/"); HtmlPasswordInput password1 = configurePage.getElementByName("user.password"); @@ -219,7 +219,7 @@ public class HudsonPrivateSecurityRealmFIPSTest { User u1 = securityRealm.createAccount("test", "aValidFipsPass"); WebClient wc = j.createWebClient(); - wc.login("test","aValidFipsPass"); + wc.login("test", "aValidFipsPass"); HtmlPage configurePage = wc.goTo(u1.getUrl() + "/security/"); HtmlPasswordInput password1 = configurePage.getElementByName("user.password"); diff --git a/test/src/test/java/hudson/util/FormFieldValidatorTest.java b/test/src/test/java/hudson/util/FormFieldValidatorTest.java index 6e1b52c45c..15ef9c211f 100644 --- a/test/src/test/java/hudson/util/FormFieldValidatorTest.java +++ b/test/src/test/java/hudson/util/FormFieldValidatorTest.java @@ -185,7 +185,7 @@ public class FormFieldValidatorTest { private Secret populatedPassword = Secret.fromString("secret!"); private String textarea; private Secret emptySecretTextarea; - private Secret populatedSecretTextarea = Secret.fromString("sensitive!");; + private Secret populatedSecretTextarea = Secret.fromString("sensitive!"); @DataBoundConstructor public ValidatingDescribable() { diff --git a/test/src/test/java/jenkins/model/NodesTest.java b/test/src/test/java/jenkins/model/NodesTest.java index 5b222e313a..f2c3db4201 100644 --- a/test/src/test/java/jenkins/model/NodesTest.java +++ b/test/src/test/java/jenkins/model/NodesTest.java @@ -307,7 +307,7 @@ public class NodesTest { private static class DumbSlaveNameAndRemoteFSMatcher extends TypeSafeMatcher { private final DumbSlavePair expected; - public DumbSlaveNameAndRemoteFSMatcher(DumbSlavePair expected) { + DumbSlaveNameAndRemoteFSMatcher(DumbSlavePair expected) { this.expected = expected; } diff --git a/test/src/test/java/jenkins/security/Security3430Test.java b/test/src/test/java/jenkins/security/Security3430Test.java index 09f227af48..50b59d12dc 100644 --- a/test/src/test/java/jenkins/security/Security3430Test.java +++ b/test/src/test/java/jenkins/security/Security3430Test.java @@ -156,7 +156,8 @@ public class Security3430Test { // outdated remoting.jar will fail, but up to date one passes if (requestingJarFromAgent) { final IOException ex = assertThrows(IOException.class, () -> channel.preloadJar(j.jenkins.getPluginManager().uberClassLoader, Stapler.class)); - assertThat(ex.getMessage(), containsString("No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file.")); + assertThat(ex.getMessage(), containsString( + "No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file.")); } else { assertTrue(channel.preloadJar(j.jenkins.getPluginManager().uberClassLoader, Stapler.class)); assertThat(logRecords.stream().map(LogRecord::getMessage).toList(), is(empty())); @@ -227,7 +228,8 @@ public class Security3430Test { assertThat(logRecords, not(hasItem(logMessageContainsString("Allowing URL")))); assertThat(logRecords, hasItem(logMessageContainsString("Rejecting URL: "))); } else { - assertThat(itex.getCause().getMessage(), containsString("No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file.")); + assertThat(itex.getCause().getMessage(), containsString( + "No hudson.remoting.JarURLValidator has been set for this channel, so all #fetchJar calls are rejected. This is likely a bug in Jenkins. As a workaround, try updating the agent.jar file.")); } } @@ -264,10 +266,11 @@ public class Security3430Test { private final URL controllerFilePath; private final String expectedContent; - public Exploit(URL controllerFilePath, String expectedContent) { + Exploit(URL controllerFilePath, String expectedContent) { this.controllerFilePath = controllerFilePath; this.expectedContent = expectedContent; } + @Override public Void call() throws Exception { final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); @@ -290,7 +293,7 @@ public class Security3430Test { private static final class LogMessageContainsString extends TypeSafeMatcher { private final Matcher stringMatcher; - public LogMessageContainsString(Matcher stringMatcher) { + LogMessageContainsString(Matcher stringMatcher) { this.stringMatcher = stringMatcher; }