diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 907b2ee9c3..026594a02b 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -535,7 +535,7 @@ public class ClassicPluginStrategy implements PluginStrategy { final long dirTime = archive.lastModified(); // this ZipOutputStream is reused and not created for each directory - try (ZipOutputStream wrappedZOut = new ZipOutputStream(new NullOutputStream()) { + try (ZipOutputStream wrappedZOut = new ZipOutputStream(NullOutputStream.NULL_OUTPUT_STREAM) { @Override public void putNextEntry(ZipEntry ze) throws IOException { ze.setTime(dirTime+1999); // roundup diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index d86b534fb1..b524f4b720 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -345,7 +345,7 @@ public final class TcpSlaveAgentListener extends Thread { } InputStream i = s.getInputStream(); - IOUtils.copy(i, new NullOutputStream()); + IOUtils.copy(i, NullOutputStream.NULL_OUTPUT_STREAM); s.shutdownInput(); } finally { s.close(); diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index e8f0dbc6cf..d217f1decd 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -1408,7 +1408,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas } } else { try (InputStream is = connection.getInputStream()) { - IOUtils.copy(is, new NullOutputStream()); + IOUtils.copy(is, NullOutputStream.NULL_OUTPUT_STREAM); } } } catch (SSLHandshakeException e) { diff --git a/core/src/main/java/jenkins/util/JSONSignatureValidator.java b/core/src/main/java/jenkins/util/JSONSignatureValidator.java index 5c8bc4d0ea..7e9135b47b 100644 --- a/core/src/main/java/jenkins/util/JSONSignatureValidator.java +++ b/core/src/main/java/jenkins/util/JSONSignatureValidator.java @@ -156,7 +156,7 @@ public class JSONSignatureValidator { */ private FormValidation checkSpecificSignature(JSONObject json, JSONObject signatureJson, MessageDigest digest, String digestEntry, Signature signature, String signatureEntry, String digestName) throws IOException { // this is for computing a digest to check sanity - DigestOutputStream dos = new DigestOutputStream(new NullOutputStream(), digest); + DigestOutputStream dos = new DigestOutputStream(NullOutputStream.NULL_OUTPUT_STREAM, digest); SignatureOutputStream sos = new SignatureOutputStream(signature); String providedDigest = signatureJson.optString(digestEntry, null); diff --git a/core/src/test/java/hudson/FilePathTest.java b/core/src/test/java/hudson/FilePathTest.java index 26b93b8048..e4d63df2c3 100644 --- a/core/src/test/java/hudson/FilePathTest.java +++ b/core/src/test/java/hudson/FilePathTest.java @@ -242,8 +242,8 @@ public class FilePathTest { @Test public void archiveBug() throws Exception { FilePath d = new FilePath(channels.french, temp.getRoot().getPath()); d.child("test").touch(0); - d.zip(new NullOutputStream()); - d.zip(new NullOutputStream(),"**/*"); + d.zip(NullOutputStream.NULL_OUTPUT_STREAM); + d.zip(NullOutputStream.NULL_OUTPUT_STREAM,"**/*"); } @Test public void normalization() throws Exception { diff --git a/core/src/test/java/hudson/slaves/ComputerLauncherTest.java b/core/src/test/java/hudson/slaves/ComputerLauncherTest.java index 4aa8cb2036..780946df0f 100644 --- a/core/src/test/java/hudson/slaves/ComputerLauncherTest.java +++ b/core/src/test/java/hudson/slaves/ComputerLauncherTest.java @@ -52,11 +52,11 @@ public class ComputerLauncherTest { } @Test public void jdk5() { - assertThrows(IOException.class, () -> ComputerLauncher.checkJavaVersion(new PrintStream(new NullOutputStream()), "-", new BufferedReader(new StringReader("java version \"1.5.0_22\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)\nJava HotSpot(TM) Server VM (build 1.5.0_22-b03, mixed mode)\n")))); + assertThrows(IOException.class, () -> ComputerLauncher.checkJavaVersion(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM), "-", new BufferedReader(new StringReader("java version \"1.5.0_22\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)\nJava HotSpot(TM) Server VM (build 1.5.0_22-b03, mixed mode)\n")))); } @Test public void j2sdk4() { - assertThrows(IOException.class, () -> ComputerLauncher.checkJavaVersion(new PrintStream(new NullOutputStream()), "-", new BufferedReader(new StringReader("java version \"1.4.2_19\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)\nJava HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)\n")))); + assertThrows(IOException.class, () -> ComputerLauncher.checkJavaVersion(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM), "-", new BufferedReader(new StringReader("java version \"1.4.2_19\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)\nJava HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)\n")))); } @Test public void jdk8() throws IOException { diff --git a/core/src/test/java/jenkins/RemotingJarSignatureTest.java b/core/src/test/java/jenkins/RemotingJarSignatureTest.java index 60c878b20f..7bf5ac7264 100644 --- a/core/src/test/java/jenkins/RemotingJarSignatureTest.java +++ b/core/src/test/java/jenkins/RemotingJarSignatureTest.java @@ -42,7 +42,7 @@ public class RemotingJarSignatureTest { if (name.startsWith("META-INF/") && name.endsWith(".DSA")) continue; // make sure bits are signed - IOUtils.copy(myJar.getInputStream(entry), new NullOutputStream()); + IOUtils.copy(myJar.getInputStream(entry), NullOutputStream.NULL_OUTPUT_STREAM); if (entry.getCodeSigners()==null) { fail("No signature for " + name); }