diff --git a/src/main/java/hudson/remoting/AbstractByteBufferCommandTransport.java b/src/main/java/hudson/remoting/AbstractByteBufferCommandTransport.java index 753efd813..745b81fef 100644 --- a/src/main/java/hudson/remoting/AbstractByteBufferCommandTransport.java +++ b/src/main/java/hudson/remoting/AbstractByteBufferCommandTransport.java @@ -282,11 +282,8 @@ public final synchronized void setup(final Channel channel, final CommandReceive @Override public final void write(Command cmd, boolean last) throws IOException { ByteBufferQueueOutputStream bqos = new ByteBufferQueueOutputStream(sendStaging); - ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(bqos); - try { + try (ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(bqos)) { cmd.writeTo(channel, oos); - } finally { - oos.close(); } long remaining = sendStaging.remaining(); channel.notifyWrite(cmd, remaining); diff --git a/src/main/java/hudson/remoting/AtmostOneThreadExecutor.java b/src/main/java/hudson/remoting/AtmostOneThreadExecutor.java index d9ebd88a3..b72d861ed 100644 --- a/src/main/java/hudson/remoting/AtmostOneThreadExecutor.java +++ b/src/main/java/hudson/remoting/AtmostOneThreadExecutor.java @@ -25,7 +25,7 @@ public class AtmostOneThreadExecutor extends AbstractExecutorService { */ private Thread worker; - private final LinkedList q = new LinkedList(); + private final LinkedList q = new LinkedList<>(); private boolean shutdown; @@ -59,7 +59,7 @@ private boolean isAlive() { public List shutdownNow() { synchronized (q) { shutdown = true; - List r = new ArrayList(q); + List r = new ArrayList<>(q); q.clear(); return r; } diff --git a/src/main/java/hudson/remoting/BinarySafeStream.java b/src/main/java/hudson/remoting/BinarySafeStream.java index 10697a57e..cda9fa59c 100644 --- a/src/main/java/hudson/remoting/BinarySafeStream.java +++ b/src/main/java/hudson/remoting/BinarySafeStream.java @@ -89,7 +89,7 @@ public int read() throws IOException { } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { if(remaining==-1) return -1; // EOF if(len<4) { @@ -131,7 +131,7 @@ public int read(byte b[], int off, int len) throws IOException { * The same as {@link #read(byte[], int, int)} but the buffer must be * longer than off+4, */ - private int _read(byte b[], int off, int len) throws IOException { + private int _read(byte[] b, int off, int len) throws IOException { assert remaining==0; assert b.length>=off+4; @@ -242,7 +242,7 @@ public void write(int b) throws IOException { } @Override - public void write(byte b[], int off, int len) throws IOException { + public void write(byte[] b, int off, int len) throws IOException { // if there's anything left in triplet from the last write, try to write them first if(remaining>0) { while(len>0 && remaining<3) { diff --git a/src/main/java/hudson/remoting/Channel.java b/src/main/java/hudson/remoting/Channel.java index 3d2bd7f57..fdf6e92ce 100644 --- a/src/main/java/hudson/remoting/Channel.java +++ b/src/main/java/hudson/remoting/Channel.java @@ -159,7 +159,7 @@ public class Channel implements VirtualChannel, IChannel, Closeable { * Requests that are sent to the remote side for execution, yet we are waiting locally until * we hear back their responses. */ - /*package*/ final Map> pendingCalls = new Hashtable>(); + /*package*/ final Map> pendingCalls = new Hashtable<>(); /** * Remembers last I/O ID issued from locally to the other side, per thread. @@ -171,7 +171,7 @@ public class Channel implements VirtualChannel, IChannel, Closeable { * Records the {@link Request}s being executed on this channel, sent by the remote peer. */ /*package*/ final Map> executingCalls = - Collections.synchronizedMap(new Hashtable>()); + Collections.synchronizedMap(new Hashtable<>()); /** * {@link ClassLoader}s that are proxies of the remote classloaders. @@ -200,7 +200,7 @@ public class Channel implements VirtualChannel, IChannel, Closeable { * per OID, it will only result in a temporary spike in the effective window size, * and therefore should be OK. */ - private final WeakHashMap> pipeWindows = new WeakHashMap>(); + private final WeakHashMap> pipeWindows = new WeakHashMap<>(); /** * There are cases where complex object cycles can cause a closed channel to fail to be garbage collected, * these typically arrise when an {@link #export(Class, Object)} is {@link #setProperty(Object, Object)} @@ -537,7 +537,6 @@ public Channel(String name, ExecutorService exec, CommandTransport transport, bo * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} * @param restricted * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} - * @param jarCache * * @since 2.24 * @deprecated as of 2.38 @@ -977,7 +976,7 @@ public void setJarCache(@Nonnull JarCache jarCache) { w = new Real(k, PIPE_WINDOW_SIZE); else w = new PipeWindow.Fake(); - pipeWindows.put(k,new WeakReference(w)); + pipeWindows.put(k, new WeakReference<>(w)); return w; } } @@ -997,7 +996,7 @@ V call(Callable callable) throws IOException, T, InterruptedException { UserRequest request=null; try { - request = new UserRequest(this, callable); + request = new UserRequest<>(this, callable); UserRequest.ResponseToUserRequest r = request.call(this); return r.retrieve(this, UserRequest.getClassLoader(callable)); @@ -1135,7 +1134,7 @@ public boolean removeListener(Listener l) { } /** - * Adds a {@link CallableFilter} that gets a chance to decorate every {@link Callable}s that run locally + * Adds a {@link CallableDecorator} that gets a chance to decorate every {@link Callable}s that run locally * sent by the other peer. * * This is useful to tweak the environment those closures are run, such as setting up the thread context @@ -1146,7 +1145,7 @@ public void addLocalExecutionInterceptor(CallableDecorator decorator) { } /** - * Removes the filter introduced by {@link #addLocalExecutionInterceptor(CallableFilter)}. + * Removes the filter introduced by {@link #addLocalExecutionInterceptor(CallableDecorator)}. */ public void removeLocalExecutionInterceptor(CallableDecorator decorator) { decorators.remove(decorator); @@ -1993,7 +1992,7 @@ void notifyJar(File jar) { /** * Remembers the current "channel" associated for this thread. */ - private static final ThreadLocal CURRENT = new ThreadLocal(); + private static final ThreadLocal CURRENT = new ThreadLocal<>(); private static final Logger logger = Logger.getLogger(Channel.class.getName()); @@ -2017,7 +2016,7 @@ void notifyJar(File jar) { /** * Keep track of active channels in the system for diagnostics purposes. */ - private static final Map ACTIVE_CHANNELS = Collections.synchronizedMap(new WeakHashMap()); + private static final Map ACTIVE_CHANNELS = Collections.synchronizedMap(new WeakHashMap<>()); static final Class jarLoaderProxy; diff --git a/src/main/java/hudson/remoting/ChannelBuilder.java b/src/main/java/hudson/remoting/ChannelBuilder.java index d92307a30..ae296e9a3 100644 --- a/src/main/java/hudson/remoting/ChannelBuilder.java +++ b/src/main/java/hudson/remoting/ChannelBuilder.java @@ -52,10 +52,10 @@ public class ChannelBuilder { private OutputStream header; @CheckForNull private JarCache jarCache; - private List decorators = new ArrayList(); + private List decorators = new ArrayList<>(); private boolean arbitraryCallableAllowed = true; private boolean remoteClassLoadingAllowed = true; - private final Hashtable properties = new Hashtable(); + private final Hashtable properties = new Hashtable<>(); private ClassFilter filter = ClassFilter.DEFAULT; /** @@ -273,7 +273,7 @@ public ChannelBuilder withRoles(final Collection actual) { @Override public void check(RoleSensitive subject, @Nonnull Collection expected) { if (!actual.containsAll(expected)) { - Collection c = new ArrayList(expected); + Collection c = new ArrayList<>(expected); c.removeAll(actual); throw new SecurityException("Unexpected role: " + c); } diff --git a/src/main/java/hudson/remoting/ClassFilter.java b/src/main/java/hudson/remoting/ClassFilter.java index 2b11e3c47..26661e8fc 100644 --- a/src/main/java/hudson/remoting/ClassFilter.java +++ b/src/main/java/hudson/remoting/ClassFilter.java @@ -132,7 +132,7 @@ public boolean isBlacklisted(String name) { /** * Changes the effective value of {@link #DEFAULT}. - * @param filter a new default to set; may or may not delegate to {@link STANDARD} + * @param filter a new default to set; may or may not delegate to {@link #STANDARD} * @since 3.16 */ public static void setDefault(@Nonnull ClassFilter filter) { @@ -216,7 +216,7 @@ private static List loadPatternOverride() { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(prop), Charset.defaultCharset())); - ArrayList patterns = new ArrayList(); + ArrayList patterns = new ArrayList<>(); for (String line = br.readLine(); line != null; line = br.readLine()) { try { Pattern.compile(line); diff --git a/src/main/java/hudson/remoting/Engine.java b/src/main/java/hudson/remoting/Engine.java index fc55f2747..e59d4ae4d 100644 --- a/src/main/java/hudson/remoting/Engine.java +++ b/src/main/java/hudson/remoting/Engine.java @@ -445,12 +445,12 @@ public void setKeepAlive(boolean keepAlive) { public void setCandidateCertificates(List candidateCertificates) { this.candidateCertificates = candidateCertificates == null ? null - : new ArrayList(candidateCertificates); + : new ArrayList<>(candidateCertificates); } public void addCandidateCertificate(X509Certificate certificate) { if (candidateCertificates == null) { - candidateCertificates = new ArrayList(); + candidateCertificates = new ArrayList<>(); } candidateCertificates.add(certificate); } @@ -472,8 +472,7 @@ public void run() { } // Create the engine try { - IOHub hub = IOHub.create(executor); - try { + try (IOHub hub = IOHub.create(executor)) { SSLContext context; // prepare our SSLContext try { @@ -517,8 +516,6 @@ public void run() { return; } innerRun(hub, context, executor); - } finally { - hub.close(); } } catch (IOException e) { events.error(e); @@ -867,7 +864,7 @@ public static Engine current() { return CURRENT.get(); } - private static final ThreadLocal CURRENT = new ThreadLocal(); + private static final ThreadLocal CURRENT = new ThreadLocal<>(); private static final Logger LOGGER = Logger.getLogger(Engine.class.getName()); @@ -879,7 +876,7 @@ static KeyStore getCacertsKeyStore() new PrivilegedExceptionAction>() { @Override public Map run() throws Exception { - Map result = new HashMap(); + Map result = new HashMap<>(); result.put("trustStore", System.getProperty("javax.net.ssl.trustStore")); result.put("javaHome", System.getProperty("java.home")); result.put("trustStoreType", diff --git a/src/main/java/hudson/remoting/EngineListenerSplitter.java b/src/main/java/hudson/remoting/EngineListenerSplitter.java index 462bea50d..face303d3 100644 --- a/src/main/java/hudson/remoting/EngineListenerSplitter.java +++ b/src/main/java/hudson/remoting/EngineListenerSplitter.java @@ -10,7 +10,7 @@ * @since 2.36 */ public class EngineListenerSplitter implements EngineListener { - protected final List listeners = new CopyOnWriteArrayList(); + protected final List listeners = new CopyOnWriteArrayList<>(); public void add(EngineListener el) { listeners.add(el); diff --git a/src/main/java/hudson/remoting/ExportTable.java b/src/main/java/hudson/remoting/ExportTable.java index 08ecaaed8..8b088b305 100644 --- a/src/main/java/hudson/remoting/ExportTable.java +++ b/src/main/java/hudson/remoting/ExportTable.java @@ -51,13 +51,13 @@ * @author Kohsuke Kawaguchi */ final class ExportTable { - private final Map> table = new HashMap>(); - private final Map> reverse = new HashMap>(); + private final Map> table = new HashMap<>(); + private final Map> reverse = new HashMap<>(); /** * {@link ExportList}s which are actively recording the current * export operation. */ - private final ThreadLocal lists = new ThreadLocal(); + private final ThreadLocal lists = new ThreadLocal<>(); /** * For diagnosing problems like JENKINS-20707 where we seem to be unexporting too eagerly, @@ -65,7 +65,7 @@ final class ExportTable { * * New entries are added to the end, and older ones are removed from the beginning. */ - private final List> unexportLog = new LinkedList>(); + private final List> unexportLog = new LinkedList<>(); /** * Information about one exported object. @@ -362,7 +362,7 @@ synchronized int export(@Nonnull Class clazz, @CheckForNull T t, boolean Entry e = (Entry) reverse.get(t); if (e == null) { - e = new Entry(t, clazz); + e = new Entry<>(t, clazz); } else { e.addInterface(clazz); } @@ -432,7 +432,7 @@ synchronized Class[] type(int id) throws ExecutionException { void abort(@CheckForNull Throwable e) { List> values; synchronized (this) { - values = new ArrayList>(table.values()); + values = new ArrayList<>(table.values()); } for (Entry v : values) { if (v.object instanceof ErrorPropagatingOutputStream) { diff --git a/src/main/java/hudson/remoting/ExportedClassLoaderTable.java b/src/main/java/hudson/remoting/ExportedClassLoaderTable.java index 69fdbc159..9a19106a7 100644 --- a/src/main/java/hudson/remoting/ExportedClassLoaderTable.java +++ b/src/main/java/hudson/remoting/ExportedClassLoaderTable.java @@ -35,8 +35,8 @@ * @author Kohsuke Kawaguchi */ final class ExportedClassLoaderTable { - private final Map> table = new HashMap>(); - private final WeakHashMap reverse = new WeakHashMap(); + private final Map> table = new HashMap<>(); + private final WeakHashMap reverse = new WeakHashMap<>(); // id==0 is reserved for bootstrap classloader private int iota = 1; @@ -48,7 +48,7 @@ public synchronized int intern(ClassLoader cl) { Integer id = reverse.get(cl); if(id==null) { id = iota++; - table.put(id,new WeakReference(cl)); + table.put(id, new WeakReference<>(cl)); reverse.put(cl,id); } diff --git a/src/main/java/hudson/remoting/FastPipedInputStream.java b/src/main/java/hudson/remoting/FastPipedInputStream.java index e6b310628..7385c88de 100644 --- a/src/main/java/hudson/remoting/FastPipedInputStream.java +++ b/src/main/java/hudson/remoting/FastPipedInputStream.java @@ -122,8 +122,8 @@ public void connect(FastPipedOutputStream source) throws IOException { if(this.source != null) { throw new IOException("Pipe already connected"); } - this.source = new WeakReference(source); - source.sink = new WeakReference(this); + this.source = new WeakReference<>(source); + source.sink = new WeakReference<>(this); } @Override diff --git a/src/main/java/hudson/remoting/FastPipedOutputStream.java b/src/main/java/hudson/remoting/FastPipedOutputStream.java index 720996b32..8c256342b 100644 --- a/src/main/java/hudson/remoting/FastPipedOutputStream.java +++ b/src/main/java/hudson/remoting/FastPipedOutputStream.java @@ -111,8 +111,8 @@ public void connect(FastPipedInputStream sink) throws IOException { if(this.sink != null) { throw new IOException("Pipe already connected"); } - this.sink = new WeakReference(sink); - sink.source = new WeakReference(this); + this.sink = new WeakReference<>(sink); + sink.source = new WeakReference<>(this); } @Override diff --git a/src/main/java/hudson/remoting/FileSystemJarCache.java b/src/main/java/hudson/remoting/FileSystemJarCache.java index 0e7076a9b..d95a91dd5 100644 --- a/src/main/java/hudson/remoting/FileSystemJarCache.java +++ b/src/main/java/hudson/remoting/FileSystemJarCache.java @@ -33,7 +33,7 @@ public class FileSystemJarCache extends JarCacheSupport { /** * We've reported these checksums as present on this side. */ - private final Set notified = Collections.synchronizedSet(new HashSet()); + private final Set notified = Collections.synchronizedSet(new HashSet<>()); /** * Cache of computer checksums for cached jars. @@ -111,12 +111,9 @@ protected URL retrieve(Channel channel, long sum1, long sum2) throws IOException try { File tmp = createTempJar(target); try { - RemoteOutputStream o = new RemoteOutputStream(new FileOutputStream(tmp)); - try { - LOGGER.log(Level.FINE, String.format("Retrieving jar file %16X%16X",sum1,sum2)); + try (RemoteOutputStream o = new RemoteOutputStream(new FileOutputStream(tmp))) { + LOGGER.log(Level.FINE, String.format("Retrieving jar file %16X%16X", sum1, sum2)); getJarLoader(channel).writeJarTo(sum1, sum2, o); - } finally { - o.close(); } // Verify the checksum of the download. diff --git a/src/main/java/hudson/remoting/ImportedClassLoaderTable.java b/src/main/java/hudson/remoting/ImportedClassLoaderTable.java index f35257ea6..cbafa15c4 100644 --- a/src/main/java/hudson/remoting/ImportedClassLoaderTable.java +++ b/src/main/java/hudson/remoting/ImportedClassLoaderTable.java @@ -37,7 +37,7 @@ */ final class ImportedClassLoaderTable { final Channel channel; - final Map classLoaders = new Hashtable(); + final Map classLoaders = new Hashtable<>(); ImportedClassLoaderTable(Channel channel) { this.channel = channel; diff --git a/src/main/java/hudson/remoting/InterceptingExecutorService.java b/src/main/java/hudson/remoting/InterceptingExecutorService.java index 489517ab2..c3c35629e 100644 --- a/src/main/java/hudson/remoting/InterceptingExecutorService.java +++ b/src/main/java/hudson/remoting/InterceptingExecutorService.java @@ -77,7 +77,7 @@ public V call() throws Exception { } private Collection> wrap(Collection> callables) { - List> r = new ArrayList>(); + List> r = new ArrayList<>(); for (Callable c : callables) { r.add(wrap(c)); } diff --git a/src/main/java/hudson/remoting/JarCacheSupport.java b/src/main/java/hudson/remoting/JarCacheSupport.java index a47a0881b..84ed4278f 100644 --- a/src/main/java/hudson/remoting/JarCacheSupport.java +++ b/src/main/java/hudson/remoting/JarCacheSupport.java @@ -19,7 +19,7 @@ public abstract class JarCacheSupport extends JarCache { /** * Remember in-progress jar file resolution to avoid retrieving the same jar file twice. */ - private final ConcurrentMap> inprogress = new ConcurrentHashMap>(); + private final ConcurrentMap> inprogress = new ConcurrentHashMap<>(); /** * Look up the local cache and return URL if found. @@ -46,7 +46,7 @@ public Future resolve(final Channel channel, final long sum1, final long su URL jar = lookInCache(channel,sum1, sum2); if (jar!=null) { // already in the cache - return new AsyncFutureImpl(jar); + return new AsyncFutureImpl<>(jar); } while (true) {// might have to try a few times before we get successfully resolve @@ -59,7 +59,7 @@ public Future resolve(final Channel channel, final long sum1, final long su } else { // we are going to resolve this ourselves and publish the result in 'promise' for others try { - final AsyncFutureImpl promise = new AsyncFutureImpl(); + final AsyncFutureImpl promise = new AsyncFutureImpl<>(); ExecutorServiceUtils.submitAsync(downloader, new DownloadRunnable(channel, sum1, sum2, key, promise)); // Now we are sure that the task has been accepted to the queue, hence we cache the promise // if nobody else caches it before. diff --git a/src/main/java/hudson/remoting/JarLoader.java b/src/main/java/hudson/remoting/JarLoader.java index 37c4d8a0a..dcf42263d 100644 --- a/src/main/java/hudson/remoting/JarLoader.java +++ b/src/main/java/hudson/remoting/JarLoader.java @@ -52,6 +52,6 @@ public interface JarLoader { */ boolean isPresentOnRemote(Checksum sum); - final String OURS = JarLoader.class.getName()+".ours"; - final ChannelProperty THEIRS = new ChannelProperty(JarLoader.class,"their JarLoader"); + String OURS = JarLoader.class.getName()+".ours"; + ChannelProperty THEIRS = new ChannelProperty<>(JarLoader.class, "their JarLoader"); } diff --git a/src/main/java/hudson/remoting/JarLoaderImpl.java b/src/main/java/hudson/remoting/JarLoaderImpl.java index fdf30a53a..4f4244330 100644 --- a/src/main/java/hudson/remoting/JarLoaderImpl.java +++ b/src/main/java/hudson/remoting/JarLoaderImpl.java @@ -32,7 +32,7 @@ class JarLoaderImpl implements JarLoader, SerializableOnlyOverRemoting { @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("DMI_COLLECTION_OF_URLS") // TODO: fix this private final ConcurrentMap checksums = new ConcurrentHashMap<>(); - private final Set presentOnRemote = Collections.synchronizedSet(new HashSet()); + private final Set presentOnRemote = Collections.synchronizedSet(new HashSet<>()); @Override @SuppressFBWarnings(value = {"URLCONNECTION_SSRF_FD", "PATH_TRAVERSAL_IN"}, justification = "This is only used for managing the jar cache as files, not URLs.") diff --git a/src/main/java/hudson/remoting/Launcher.java b/src/main/java/hudson/remoting/Launcher.java index 5e62c9927..ba788dd59 100644 --- a/src/main/java/hudson/remoting/Launcher.java +++ b/src/main/java/hudson/remoting/Launcher.java @@ -48,7 +48,6 @@ import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; -import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -555,7 +554,7 @@ public List parseJnlpArguments() throws ParserConfigurationException, SA // exec into the JNLP launcher, to fetch the connection parameter through JNLP. NodeList argElements = dom.getElementsByTagName("argument"); - List jnlpArgs = new ArrayList(); + List jnlpArgs = new ArrayList<>(); for( int i=0; i classLoaders = new HashMap(); + private final Map classLoaders = new HashMap<>(); Output(Channel channel, OutputStream out) throws IOException { super(out); @@ -82,7 +82,7 @@ protected void annotateProxyClass(Class cl) throws IOException { static final class Input extends ObjectInputStream { private final Channel channel; - private final List classLoaders = new ArrayList(); + private final List classLoaders = new ArrayList<>(); Input(Channel channel, InputStream in) throws IOException { super(in); diff --git a/src/main/java/hudson/remoting/PipeWriter.java b/src/main/java/hudson/remoting/PipeWriter.java index 76a08d2e6..58a4b8c02 100644 --- a/src/main/java/hudson/remoting/PipeWriter.java +++ b/src/main/java/hudson/remoting/PipeWriter.java @@ -111,7 +111,7 @@ public synchronized Future get() throws InterruptedException { } } - private final Map pendingIO = Collections.synchronizedMap(new HashMap()); + private final Map pendingIO = Collections.synchronizedMap(new HashMap<>()); /** * Actually carries out the {@link Runnable}s. @@ -184,5 +184,5 @@ public Future get(int id) throws InterruptedException { return f.get(); } - private static final Future SIGNALED = new AsyncFutureImpl(new Object()); + private static final Future SIGNALED = new AsyncFutureImpl<>(new Object()); } diff --git a/src/main/java/hudson/remoting/ProxyInputStream.java b/src/main/java/hudson/remoting/ProxyInputStream.java index f949f78d4..e18a03be2 100644 --- a/src/main/java/hudson/remoting/ProxyInputStream.java +++ b/src/main/java/hudson/remoting/ProxyInputStream.java @@ -81,7 +81,7 @@ private synchronized Buffer _read(int len) throws IOException, InterruptedExcept } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { try { Buffer buf = _read(len); if(buf.len==-1) return -1; diff --git a/src/main/java/hudson/remoting/ReferenceCountRecorder.java b/src/main/java/hudson/remoting/ReferenceCountRecorder.java index 15d785ffa..07c159ea8 100644 --- a/src/main/java/hudson/remoting/ReferenceCountRecorder.java +++ b/src/main/java/hudson/remoting/ReferenceCountRecorder.java @@ -25,7 +25,7 @@ class ReferenceCountRecorder { */ private int total; - private LinkedList events = new LinkedList(); + private LinkedList events = new LinkedList<>(); ReferenceCountRecorder(int cap) { this.cap = cap; diff --git a/src/main/java/hudson/remoting/RemoteInvocationHandler.java b/src/main/java/hudson/remoting/RemoteInvocationHandler.java index 0938797ed..22d752f42 100644 --- a/src/main/java/hudson/remoting/RemoteInvocationHandler.java +++ b/src/main/java/hudson/remoting/RemoteInvocationHandler.java @@ -488,12 +488,12 @@ private static class Unexporter implements Runnable { * Our {@link ReferenceQueue} for picking up references that have been collected by the garbage collector * and need the corresponding {@link UnexportCommand} sent. */ - private final ReferenceQueue queue = new ReferenceQueue(); + private final ReferenceQueue queue = new ReferenceQueue<>(); /** * The "live" {@link PhantomReferenceImpl} instances for each active {@link Channel}. */ private final ConcurrentMap> referenceLists - = new ConcurrentHashMap>(); + = new ConcurrentHashMap<>(); /** * The 1 minute rolling average. */ @@ -811,7 +811,7 @@ private void watch(RemoteInvocationHandler handler) { } List referenceList; while (null == (referenceList = referenceLists.get(ref))) { - referenceLists.putIfAbsent(ref, Collections.synchronizedList(new ArrayList())); + referenceLists.putIfAbsent(ref, Collections.synchronizedList(new ArrayList<>())); } referenceList.add(new PhantomReferenceImpl(handler, queue)); if (isAlive.get()) { diff --git a/src/main/java/hudson/remoting/Request.java b/src/main/java/hudson/remoting/Request.java index c2e86f152..32919478b 100644 --- a/src/main/java/hudson/remoting/Request.java +++ b/src/main/java/hudson/remoting/Request.java @@ -377,7 +377,7 @@ public void run() { rsp = new Response(Request.this, id, calcLastIoId(), r); } catch (Throwable t) { // error return - rsp = new Response(Request.this, id, calcLastIoId(), t); + rsp = new Response<>(Request.this, id, calcLastIoId(), t); } finally { CURRENT.set(null); } @@ -425,7 +425,7 @@ public void run() { * with earlier version of remoting without losing the original fix to JENKINS-9189 completely. */ @Deprecated - /*package*/ static ThreadLocal> CURRENT = new ThreadLocal>(); + /*package*/ static ThreadLocal> CURRENT = new ThreadLocal<>(); /*package*/ static int getCurrentRequestId() { Request r = CURRENT.get(); diff --git a/src/main/java/hudson/remoting/ResourceImageDirect.java b/src/main/java/hudson/remoting/ResourceImageDirect.java index 291dc479f..b9ff09572 100644 --- a/src/main/java/hudson/remoting/ResourceImageDirect.java +++ b/src/main/java/hudson/remoting/ResourceImageDirect.java @@ -35,12 +35,12 @@ class ResourceImageDirect extends ResourceImageRef { @Override Future resolve(Channel channel, String resourcePath) throws IOException, InterruptedException { LOGGER.log(Level.FINE, resourcePath+" image is direct"); - return new AsyncFutureImpl(payload); + return new AsyncFutureImpl<>(payload); } @Override Future resolveURL(Channel channel, String resourcePath) throws IOException, InterruptedException { - return new AsyncFutureImpl(URLish.from(makeResource(resourcePath, payload))); + return new AsyncFutureImpl<>(URLish.from(makeResource(resourcePath, payload))); } private static final Logger LOGGER = Logger.getLogger(ResourceImageDirect.class.getName()); diff --git a/src/main/java/hudson/remoting/SingleLaneExecutorService.java b/src/main/java/hudson/remoting/SingleLaneExecutorService.java index e4d0f3e9a..f118474b1 100644 --- a/src/main/java/hudson/remoting/SingleLaneExecutorService.java +++ b/src/main/java/hudson/remoting/SingleLaneExecutorService.java @@ -37,7 +37,7 @@ public class SingleLaneExecutorService extends AbstractExecutorService { private final ExecutorService base; - private final Queue tasks = new LinkedBlockingQueue(); + private final Queue tasks = new LinkedBlockingQueue<>(); private boolean scheduled; /** * We are being shut down. No further submissions are allowed but existing tasks can continue. @@ -80,7 +80,7 @@ public synchronized void shutdown() { @Override public synchronized List shutdownNow() { shuttingDown = shutDown = true; - List all = new LinkedList(tasks); + List all = new LinkedList<>(tasks); tasks.clear(); return all; } diff --git a/src/main/java/hudson/remoting/UserRequest.java b/src/main/java/hudson/remoting/UserRequest.java index ecd34dc35..8662cb08c 100644 --- a/src/main/java/hudson/remoting/UserRequest.java +++ b/src/main/java/hudson/remoting/UserRequest.java @@ -242,7 +242,7 @@ protected ResponseToUserRequest perform(Channel channel) throws EXC { // perhaps the thrown runtime exception is of type we can't handle response = serialize(new ProxyException(e), channel); } - return new UserResponse(response,true); + return new UserResponse<>(response, true); } catch (IOException x) { // throw it as a lower-level exception throw (EXC)x; diff --git a/src/main/java/hudson/remoting/jnlp/Main.java b/src/main/java/hudson/remoting/jnlp/Main.java index ac51739b4..7e7ab7049 100644 --- a/src/main/java/hudson/remoting/jnlp/Main.java +++ b/src/main/java/hudson/remoting/jnlp/Main.java @@ -224,7 +224,7 @@ public class Main { * Two mandatory parameters: secret key, and agent name. */ @Argument - public List args = new ArrayList(); + public List args = new ArrayList<>(); public static void main(String[] args) throws IOException, InterruptedException { try { @@ -341,7 +341,7 @@ public Engine createEngine() { } catch (CertificateException e) { throw new IllegalStateException("Java platform specification mandates support for X.509", e); } - List certificates = new ArrayList(candidateCertificates.size()); + List certificates = new ArrayList<>(candidateCertificates.size()); for (String certOrAtFilename : candidateCertificates) { certOrAtFilename = certOrAtFilename.trim(); byte[] cert; diff --git a/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpoint.java b/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpoint.java index 38e18260b..872c1e320 100644 --- a/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpoint.java +++ b/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpoint.java @@ -42,6 +42,7 @@ import java.security.interfaces.RSAPublicKey; import java.util.Collections; import java.util.LinkedHashSet; +import java.util.Objects; import java.util.Set; /** @@ -103,7 +104,7 @@ public JnlpAgentEndpoint(@Nonnull String host, int port, @CheckForNull RSAPublic this.host = host; this.port = port; this.publicKey = publicKey; - this.protocols = protocols == null || protocols.isEmpty() ? null : Collections.unmodifiableSet(new LinkedHashSet(protocols)); + this.protocols = protocols == null || protocols.isEmpty() ? null : Collections.unmodifiableSet(new LinkedHashSet<>(protocols)); this.serviceUrl = serviceURL; } @@ -276,7 +277,7 @@ public boolean equals(Object o) { if (!KeyUtils.equals(publicKey, that.publicKey)) { return false; } - if (protocols == null ? that.protocols != null : !protocols.equals(that.protocols)) { + if (!Objects.equals(protocols, that.protocols)) { return false; } if (host.equals(that.host)) { diff --git a/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpointResolver.java b/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpointResolver.java index 086132a45..0a3ad4fc4 100644 --- a/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpointResolver.java +++ b/src/main/java/org/jenkinsci/remoting/engine/JnlpAgentEndpointResolver.java @@ -60,7 +60,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; -import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; @@ -107,7 +106,7 @@ public class JnlpAgentEndpointResolver extends JnlpEndpointResolver { System.getProperty(JnlpAgentEndpointResolver.class.getName() + ".protocolNamesToTry"); public JnlpAgentEndpointResolver(String... jenkinsUrls) { - this.jenkinsUrls = new ArrayList(Arrays.asList(jenkinsUrls)); + this.jenkinsUrls = new ArrayList<>(Arrays.asList(jenkinsUrls)); } public JnlpAgentEndpointResolver(@Nonnull List jenkinsUrls) { @@ -179,7 +178,6 @@ public boolean isDisableHttpsCertValidation() { * Sets if the HTTPs certificate check should be disabled. * * This behavior is not recommended. - * @param disableHttpsCertValidation */ public void setDisableHttpsCertValidation(boolean disableHttpsCertValidation) { this.disableHttpsCertValidation = disableHttpsCertValidation; @@ -245,7 +243,7 @@ public JnlpAgentEndpoint resolve() throws IOException { List protocols = header(con, "X-Jenkins-Agent-Protocols"); if (protocols != null) { // Take the list of protocols to try from the headers - agentProtocolNames = new HashSet(); + agentProtocolNames = new HashSet<>(); for (String names : protocols) { for (String name : names.split(",")) { name = name.trim(); @@ -268,7 +266,7 @@ public JnlpAgentEndpoint resolve() throws IOException { if (PROTOCOL_NAMES_TO_TRY != null) { // Take a list of protocols to try from the system property - agentProtocolNames = new HashSet(); + agentProtocolNames = new HashSet<>(); LOGGER.log(Level.INFO, "Ignoring the list of supported remoting protocols provided by the server, because the " + "'org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.protocolNamesToTry' property is defined. Will try {0}", PROTOCOL_NAMES_TO_TRY); for (String name : PROTOCOL_NAMES_TO_TRY.split(",")) { @@ -323,7 +321,7 @@ public JnlpAgentEndpoint resolve() throws IOException { } // sort the URLs so that the winner is the one we try first next time final String winningJenkinsUrl = jenkinsUrl; - Collections.sort(jenkinsUrls, new Comparator() { + jenkinsUrls.sort(new Comparator() { @Override public int compare(String o1, String o2) { if (winningJenkinsUrl.equals(o1)) { diff --git a/src/main/java/org/jenkinsci/remoting/engine/JnlpClientDatabase.java b/src/main/java/org/jenkinsci/remoting/engine/JnlpClientDatabase.java index 8284063a8..ad97bb0f0 100644 --- a/src/main/java/org/jenkinsci/remoting/engine/JnlpClientDatabase.java +++ b/src/main/java/org/jenkinsci/remoting/engine/JnlpClientDatabase.java @@ -78,6 +78,6 @@ public enum ValidationResult { /** * The certificate is valid and proven to originate from the named client, skip secret validation. */ - IDENTITY_PROVED; + IDENTITY_PROVED } } diff --git a/src/main/java/org/jenkinsci/remoting/engine/JnlpConnectionState.java b/src/main/java/org/jenkinsci/remoting/engine/JnlpConnectionState.java index 9724c88ea..98f01fc8a 100644 --- a/src/main/java/org/jenkinsci/remoting/engine/JnlpConnectionState.java +++ b/src/main/java/org/jenkinsci/remoting/engine/JnlpConnectionState.java @@ -53,7 +53,7 @@ public class JnlpConnectionState { * The current iterator being used to process the listener notifications. */ private static final ThreadLocal> fireIterator - = new ThreadLocal>(); + = new ThreadLocal<>(); /** * The property name for the secret key. @@ -128,7 +128,7 @@ public class JnlpConnectionState { */ public JnlpConnectionState(@Nullable Socket socket, List listeners) { this.socket = socket; - this.listeners = new ArrayList(listeners); + this.listeners = new ArrayList<>(listeners); } /** @@ -385,7 +385,7 @@ public void fireAfterProperties(@Nonnull Map properties) throws if (lifecycle != State.BEFORE_PROPERTIES) { throw new IllegalStateException("fireAfterProperties cannot be invoked at lifecycle " + lifecycle); } - this.properties = new HashMap(properties); + this.properties = new HashMap<>(properties); lifecycle = State.AFTER_PROPERTIES; // TODO fire(JnlpConnectionStateListener::afterProperties); fire(new EventHandler() { diff --git a/src/main/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerFactory.java b/src/main/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerFactory.java index 150204a93..e9597da96 100644 --- a/src/main/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerFactory.java +++ b/src/main/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerFactory.java @@ -161,7 +161,7 @@ public JnlpProtocolHandlerFactory withClientDatabase(@CheckForNull JnlpClientDat */ @Nonnull public List> handlers() { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); if (ioHub != null && context != null) { result.add(new JnlpProtocol4Handler(clientDatabase, threadPool, ioHub, context, needClientAuth, preferNio)); } diff --git a/src/main/java/org/jenkinsci/remoting/nio/NioChannelHub.java b/src/main/java/org/jenkinsci/remoting/nio/NioChannelHub.java index c9ef3451b..f0e6b6b15 100644 --- a/src/main/java/org/jenkinsci/remoting/nio/NioChannelHub.java +++ b/src/main/java/org/jenkinsci/remoting/nio/NioChannelHub.java @@ -67,7 +67,7 @@ public class NioChannelHub implements Runnable, Closeable { * Used to schedule work that can be only done synchronously with the {@link Selector#select()} call. */ private final Queue> selectorTasks - = new ConcurrentLinkedQueue>(); + = new ConcurrentLinkedQueue<>(); /** * {@link ExecutorService} that processes command parsing and executions. @@ -216,7 +216,7 @@ public void abort(Throwable e) { if (receiver == null) { throw new IllegalStateException("Aborting connection before it has been actually set up"); } - receiver.terminate((IOException) new IOException("Connection aborted: "+this, e)); + receiver.terminate(new IOException("Connection aborted: "+this, e)); } @Override @@ -731,7 +731,7 @@ protected void onSelected(SelectionKey key) { @SelectorThreadOnly private void abortAll(Throwable e) { - Set pairs = new HashSet(); + Set pairs = new HashSet<>(); for (SelectionKey k : selector.keys()) pairs.add((NioTransport)k.attachment()); for (NioTransport p : pairs) diff --git a/src/main/java/org/jenkinsci/remoting/org/apache/commons/net/util/SubnetUtils.java b/src/main/java/org/jenkinsci/remoting/org/apache/commons/net/util/SubnetUtils.java index 994a04a71..9229ec63b 100644 --- a/src/main/java/org/jenkinsci/remoting/org/apache/commons/net/util/SubnetUtils.java +++ b/src/main/java/org/jenkinsci/remoting/org/apache/commons/net/util/SubnetUtils.java @@ -311,7 +311,7 @@ private int matchAddress(Matcher matcher) { * Convert a packed integer address into a 4-element array */ private int[] toArray(int val) { - int ret[] = new int[4]; + int[] ret = new int[4]; for (int j = 3; j >= 0; --j) { ret[j] |= ((val >>> 8*(3-j)) & (0xff)); } diff --git a/src/main/java/org/jenkinsci/remoting/org/apache/commons/validator/routines/InetAddressValidator.java b/src/main/java/org/jenkinsci/remoting/org/apache/commons/validator/routines/InetAddressValidator.java index 2f409fe36..9c2c7c348 100644 --- a/src/main/java/org/jenkinsci/remoting/org/apache/commons/validator/routines/InetAddressValidator.java +++ b/src/main/java/org/jenkinsci/remoting/org/apache/commons/validator/routines/InetAddressValidator.java @@ -142,7 +142,7 @@ public boolean isValidInet6Address(String inet6Address) { } String[] octets = inet6Address.split(":"); if (containsCompressedZeroes) { - List octetList = new ArrayList(Arrays.asList(octets)); + List octetList = new ArrayList<>(Arrays.asList(octets)); if (inet6Address.endsWith("::")) { // String.split() drops ending empty segments octetList.add(""); diff --git a/src/main/java/org/jenkinsci/remoting/protocol/IOHub.java b/src/main/java/org/jenkinsci/remoting/protocol/IOHub.java index 3c1c193fc..497fefbc3 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/IOHub.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/IOHub.java @@ -102,23 +102,23 @@ public class IOHub implements Executor, Closeable, Runnable, ByteBufferPool { /** * The scheduled tasks to run later. */ - private final DelayQueue scheduledTasks = new DelayQueue(); + private final DelayQueue scheduledTasks = new DelayQueue<>(); /** * Tasks to run on the selector thread. */ - private final Queue selectorTasks = new ConcurrentLinkedQueue(); + private final Queue selectorTasks = new ConcurrentLinkedQueue<>(); /** * Registrations to process (these must take place on the selector thread). We could process these using * a {@link Runnable} on {@link #selectorTasks} but we want to optimize detecting when to call * {@link Selector#selectNow()}. */ - private final Queue registrations = new ConcurrentLinkedQueue(); + private final Queue registrations = new ConcurrentLinkedQueue<>(); /** * {@link SelectionKey#interestOps()} modifications to process (these are safer taking place on the selector * thread).We could process these using a {@link Runnable} on {@link #selectorTasks} but we want to optimize * detecting when to call {@link Selector#selectNow()}. */ - private final Queue interestOps = new ConcurrentLinkedQueue(); + private final Queue interestOps = new ConcurrentLinkedQueue<>(); /** * Counts the # of select loops. Ocassionally useful for diagnosing whether the selector * thread is spending too much CPU time. @@ -577,7 +577,7 @@ private void processScheduledTasks() { if (tasksWaiting > 4) { // DelayQueue.drainTo is more efficient than repeated polling // but we don't want to create the ArrayList every time the selector loops - List scheduledWork = new ArrayList(); + List scheduledWork = new ArrayList<>(); scheduledTasks.drainTo(scheduledWork); for (DelayedRunnable task : scheduledWork) { if (!task.isCancelled()) { @@ -921,7 +921,7 @@ public synchronized int compareTo(Delayed o) { // we want to compare based on the delay long x = getDelay(TimeUnit.NANOSECONDS); long y = o.getDelay(TimeUnit.NANOSECONDS); - return (x < y) ? -1 : ((x == y) ? 0 : 1); + return Long.compare(x, y); } /** diff --git a/src/main/java/org/jenkinsci/remoting/protocol/ProtocolStack.java b/src/main/java/org/jenkinsci/remoting/protocol/ProtocolStack.java index 0ebad9f25..0bcd0bd8f 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/ProtocolStack.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/ProtocolStack.java @@ -30,6 +30,7 @@ import java.nio.channels.ClosedChannelException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -140,7 +141,7 @@ public class ProtocolStack implements Closeable, ByteBufferPool { * Our listeners. */ @GuardedBy("stackLock") - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); private final long handshakingTimeout = 10L; @@ -243,7 +244,7 @@ public String name() { * @param name the new name of this stack to use in logging. */ public void name(String name) { - if (!(this.name == null ? name == null : this.name.equals(name))) { + if (!(Objects.equals(this.name, name))) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, "[{0}] is now known as [{1}]", new Object[]{this.name, name}); } @@ -361,7 +362,7 @@ public String toString() { * @param cause the cause or {@code null} if the close was "normal". */ /*package*/ void onClosed(IOException cause) { - final List listeners = new ArrayList(); + final List listeners = new ArrayList<>(); stackLock.readLock().lock(); try { listeners.addAll(this.listeners); @@ -462,7 +463,7 @@ public static class Builder { /** * The initial listeners to register. */ - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); /** * The name to give the protocol stack. @@ -485,7 +486,7 @@ private Builder(NetworkLayer network) { throw new IllegalArgumentException(); } this.network = network; - this.filters = new ArrayList(); + this.filters = new ArrayList<>(); } /** @@ -545,7 +546,7 @@ public ProtocolStack build(ApplicationLayer application) throws IOExce checkNotBuilt(); built = true; ProtocolStack stack = - new ProtocolStack( + new ProtocolStack<>( name == null || name.isEmpty() ? String.format("Stack-%d", id.incrementAndGet()) : name, network, filters, @@ -637,7 +638,7 @@ private Ptr(Ptr nextSend, FilterLayer filter) { * @param nextSend the previous {@link Ptr}. * @param application the {@link ApplicationLayer} */ - private Ptr(Ptr nextSend, ApplicationLayer application) { + private Ptr(Ptr nextSend, ApplicationLayer application) { stackLock.writeLock().lock(); try { this.nextSend = nextSend; @@ -825,7 +826,7 @@ public void onRecvClosed(IOException cause) throws IOException { */ @Nonnull private ProtocolLayer.Send nextSend() { - return (ProtocolLayer.Send) (getNextSend().layer); + return (ProtocolLayer.Send) getNextSend().layer; } /** @@ -878,7 +879,7 @@ private Ptr getNextSend() { */ @Nonnull private ProtocolLayer.Recv nextRecv() { - return (ProtocolLayer.Recv) (getNextRecv().layer); + return (ProtocolLayer.Recv) getNextRecv().layer; } /** diff --git a/src/main/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManager.java b/src/main/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManager.java index f879525d2..ae9d7675c 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManager.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManager.java @@ -97,7 +97,7 @@ public PublicKeyMatchingX509ExtendedTrustManager(PublicKey... publicKeys) { */ public PublicKeyMatchingX509ExtendedTrustManager(boolean strictClient, boolean strictServer, PublicKey... publicKeys) { - this.publicKeys = new ArrayList(Arrays.asList(publicKeys)); + this.publicKeys = new ArrayList<>(Arrays.asList(publicKeys)); this.strictClient = strictClient; this.strictServer = strictServer; } diff --git a/src/main/java/org/jenkinsci/remoting/protocol/impl/ChannelApplicationLayer.java b/src/main/java/org/jenkinsci/remoting/protocol/impl/ChannelApplicationLayer.java index 918c9aa00..5e73072ef 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/impl/ChannelApplicationLayer.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/impl/ChannelApplicationLayer.java @@ -220,11 +220,8 @@ public void onReadClosed(IOException cause) throws IOException { public void start() throws IOException { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(BinarySafeStream.wrap(bos)); - try { + try (ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(BinarySafeStream.wrap(bos))) { oos.writeObject(new Capability()); - } finally { - oos.close(); } ByteBuffer buffer = ByteBufferUtils.wrapUTF8(bos.toString("US-ASCII")); write(buffer); diff --git a/src/main/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeaders.java b/src/main/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeaders.java index 933e1f0f1..f4c19c706 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeaders.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeaders.java @@ -108,7 +108,7 @@ public static String toString(@Nonnull Map data) { */ @Nonnull public static Map fromString(@Nonnull String data) throws ParseException { - Map result = new TreeMap(); + Map result = new TreeMap<>(); int state = 0; StringBuilder key = new StringBuilder(); StringBuilder val = new StringBuilder(); diff --git a/src/main/java/org/jenkinsci/remoting/protocol/impl/NIONetworkLayer.java b/src/main/java/org/jenkinsci/remoting/protocol/impl/NIONetworkLayer.java index b21d6a2ac..dc2516ca5 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/impl/NIONetworkLayer.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/impl/NIONetworkLayer.java @@ -416,5 +416,4 @@ public void onClosedChannel(ClosedChannelException e) { } } - ; } diff --git a/src/main/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayer.java b/src/main/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayer.java index 46a447133..fd71c3edc 100644 --- a/src/main/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayer.java +++ b/src/main/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayer.java @@ -70,13 +70,13 @@ public class SSLEngineFilterLayer extends FilterLayer { * The queue of messages to send, populated while waiting on handshaking to complete. */ @Nonnull - private ConcurrentLinkedQueue messages = new ConcurrentLinkedQueue(); + private ConcurrentLinkedQueue messages = new ConcurrentLinkedQueue<>(); /** * Buffer to hold any partial reads until we have a complete SSL record. */ @CheckForNull private ByteBuffer previous; - private final AtomicReference directBufferRef = new AtomicReference(); + private final AtomicReference directBufferRef = new AtomicReference<>(); /** * Constructs a new instance. @@ -541,7 +541,7 @@ enum State { /** * Secure credentials are removed from the session, application messages are not encrypted anymore. */ - NO_CREDENTIALS; + NO_CREDENTIALS } } diff --git a/src/main/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStream.java b/src/main/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStream.java index a3abbe5e6..58e830ca3 100644 --- a/src/main/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStream.java +++ b/src/main/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStream.java @@ -76,7 +76,7 @@ public int read(byte[] b, int off, int len) throws IOException { if (rem <= 0) { return -1; } - int read = queue.get(b, off, len > rem ? rem : len); + int read = queue.get(b, off, Math.min(len, rem)); if (read <= 0) { return -1; } diff --git a/src/main/java/org/jenkinsci/remoting/util/KeyUtils.java b/src/main/java/org/jenkinsci/remoting/util/KeyUtils.java index a8919949e..b0d735e1b 100644 --- a/src/main/java/org/jenkinsci/remoting/util/KeyUtils.java +++ b/src/main/java/org/jenkinsci/remoting/util/KeyUtils.java @@ -28,6 +28,7 @@ import java.security.Key; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Objects; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -83,7 +84,7 @@ public static boolean equals(Key key1, Key key2) { * @return {@code true} if the two strings are equal. */ private static boolean equals(String str1, String str2) { - return str1 == null ? str2 == null : str1.equals(str2); + return Objects.equals(str1, str2); } /** diff --git a/src/main/java/org/jenkinsci/remoting/util/SettableFuture.java b/src/main/java/org/jenkinsci/remoting/util/SettableFuture.java index 5ca1228d8..999d19c93 100644 --- a/src/main/java/org/jenkinsci/remoting/util/SettableFuture.java +++ b/src/main/java/org/jenkinsci/remoting/util/SettableFuture.java @@ -85,7 +85,7 @@ public final class SettableFuture implements ListenableFuture { /** * The listeners to notify. */ - private final Queue> listeners = new LinkedList>(); + private final Queue> listeners = new LinkedList<>(); /** * Flag to indicate that the listeners have been/are being notified and thus * {@link #addListener(Runnable, Executor)} should execute immediately (which is OK as we do not guarantee order of @@ -101,7 +101,7 @@ public final class SettableFuture implements ListenableFuture { * @return a new {@link SettableFuture}. */ public static SettableFuture create() { - return new SettableFuture(); + return new SettableFuture<>(); } /** @@ -263,7 +263,7 @@ public void addListener(@Nonnull Runnable listener, @Nonnull Executor executor) boolean executeImmediate = false; synchronized (listeners) { if (!notified) { - listeners.add(new AbstractMap.SimpleImmutableEntry(listener, executor)); + listeners.add(new AbstractMap.SimpleImmutableEntry<>(listener, executor)); } else { executeImmediate = true; } diff --git a/src/main/java/org/jenkinsci/remoting/util/VersionNumber.java b/src/main/java/org/jenkinsci/remoting/util/VersionNumber.java index c3bf647f3..323cb6bb4 100644 --- a/src/main/java/org/jenkinsci/remoting/util/VersionNumber.java +++ b/src/main/java/org/jenkinsci/remoting/util/VersionNumber.java @@ -256,9 +256,6 @@ public boolean isNull() { * just returning an Integer with the index here is faster, but requires a lot of if/then/else to check for -1 * or QUALIFIERS.size and then resort to lexical ordering. Most comparisons are decided by the first character, * so this is still fast. If more characters are needed then it requires a lexical sort anyway. - * - * @param qualifier - * @return */ public static String comparableQualifier(String qualifier) { int i = _QUALIFIERS.indexOf(qualifier); @@ -413,7 +410,7 @@ private void parseVersion(String version) { ListItem list = items; - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(list); boolean isDigit = false; @@ -518,7 +515,7 @@ public int compareTo(VersionNumber o) { } int i1 = Integer.parseInt(snapshot.substring(17)); int i2 = Integer.parseInt(o.snapshot.substring(17)); - return (i1 < i2) ? -1 : ((i1 == i2) ? 0 : 1); + return Integer.compare(i1, i2); } @Override diff --git a/src/test/java/Driver8703.java b/src/test/java/Driver8703.java index e86ba7313..37be81df6 100644 --- a/src/test/java/Driver8703.java +++ b/src/test/java/Driver8703.java @@ -1,5 +1,5 @@ import hudson.remoting.PipeTest; -import org.jvnet.hudson.test.Bug; +import org.jvnet.hudson.test.Issue; import java.util.ArrayList; import java.util.List; @@ -13,7 +13,7 @@ * @author Kohsuke Kawaguchi */ public class Driver8703 { - @Bug(8703) + @Issue("JENKINS-8703") public static void main(String[] args) throws Throwable { // int i=0; // while (true) { diff --git a/src/test/java/hudson/remoting/ChannelTest.java b/src/test/java/hudson/remoting/ChannelTest.java index 22c9ded96..143778046 100644 --- a/src/test/java/hudson/remoting/ChannelTest.java +++ b/src/test/java/hudson/remoting/ChannelTest.java @@ -2,7 +2,6 @@ import hudson.remoting.util.GCTask; import org.jenkinsci.remoting.SerializableOnlyOverRemoting; -import org.jvnet.hudson.test.Bug; import java.io.IOException; import java.io.ObjectInputStream; @@ -31,7 +30,7 @@ public void testCapability() { assertTrue(channel.remoteCapability.supportsMultiClassLoaderRPC()); } - @Bug(9050) + @Issue("JENKINS-9050") public void testFailureInDeserialization() throws Exception { try { channel.call(new CallableImpl()); @@ -45,11 +44,11 @@ public void testFailureInDeserialization() throws Exception { private static class CallableImpl extends CallableBase { @Override - public Object call() throws IOException { + public Object call() { return null; } - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + private void readObject(ObjectInputStream ois) { throw new ClassCastException("foobar"); } private static final long serialVersionUID = 1L; @@ -58,7 +57,7 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound /** * Objects exported during the request arg capturing is subject to caller auto-deallocation. */ - @Bug(10424) + @Issue("JENKINS-10424") public void testExportCallerDeallocation() throws Exception { for (int i=0; i<100; i++) { final GreeterImpl g = new GreeterImpl(); @@ -71,7 +70,7 @@ public void testExportCallerDeallocation() throws Exception { /** * Objects exported outside the request context should be deallocated by the callee. */ - @Bug(10424) + @Issue("JENKINS-10424") public void testExportCalleeDeallocation() throws Exception { for (int j=0; j<10; j++) { final GreeterImpl g = new GreeterImpl(); @@ -155,7 +154,7 @@ public GreetingTask(Greeter g) { } @Override - public Object call() throws IOException { + public Object call() { g.greet("Kohsuke"); return null; } @@ -183,7 +182,7 @@ public T call() throws RuntimeException { private static final long serialVersionUID = 1L; } - @Bug(39150) + @Issue("JENKINS-39150") public void testDiagnostics() { StringWriter sw = new StringWriter(); Channel.dumpDiagnosticsForAll(new PrintWriter(sw)); @@ -232,7 +231,7 @@ private static class ThrowingCallable extends CallableBase { * Checks if {@link UserRequest}s can be executed during the pending close operation. * @throws Exception Test Error */ - @Bug(45023) + @Issue("JENKINS-45023") public void testShouldNotAcceptUserRequestsWhenIsBeingClosed() throws Exception { // Create a sample request to the channel @@ -290,7 +289,7 @@ private static class RMIObjectExportedCallable implements Callable channelR Enumeration en = tests(); while (en.hasMoreElements()) { - Test test = (Test) en.nextElement(); + Test test = en.nextElement(); if(test instanceof RmiTestBase && channelRunner!=null) { ((RmiTestBase)test).setChannelRunner(channelRunner); diff --git a/src/test/java/hudson/remoting/ChunkedInputStreamTest.java b/src/test/java/hudson/remoting/ChunkedInputStreamTest.java index 56a910ed9..f782b4a7c 100644 --- a/src/test/java/hudson/remoting/ChunkedInputStreamTest.java +++ b/src/test/java/hudson/remoting/ChunkedInputStreamTest.java @@ -13,7 +13,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Random; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; diff --git a/src/test/java/hudson/remoting/ClassFilterTest.java b/src/test/java/hudson/remoting/ClassFilterTest.java index 753afc3ff..73f9ad0a4 100644 --- a/src/test/java/hudson/remoting/ClassFilterTest.java +++ b/src/test/java/hudson/remoting/ClassFilterTest.java @@ -285,7 +285,7 @@ public Security218Callable(Security218 a) { } @Override - public Void call() throws IOException { + public Void call() { a.toString(); // this will ensure 'a' gets sent over return null; } diff --git a/src/test/java/hudson/remoting/DefaultClassFilterTest.java b/src/test/java/hudson/remoting/DefaultClassFilterTest.java index 40e3d962f..c65af429d 100644 --- a/src/test/java/hudson/remoting/DefaultClassFilterTest.java +++ b/src/test/java/hudson/remoting/DefaultClassFilterTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.core.Every.everyItem; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.File; import java.io.FileOutputStream; @@ -146,11 +146,11 @@ public static Matcher blacklisted() { public boolean matches(Object item) { try { ClassFilter.createDefaultInstance().check(item.toString()); - return Boolean.FALSE; + return false; } catch (ClassFilter.ClassFilterException ex) { throw new IllegalStateException("Failed to initialize the default class filter", ex); } catch (SecurityException sex) { - return Boolean.TRUE; + return true; } } diff --git a/src/test/java/hudson/remoting/FileSystemJarCacheTest.java b/src/test/java/hudson/remoting/FileSystemJarCacheTest.java index 6ab8a36a3..cc23a7fa4 100644 --- a/src/test/java/hudson/remoting/FileSystemJarCacheTest.java +++ b/src/test/java/hudson/remoting/FileSystemJarCacheTest.java @@ -8,7 +8,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.jvnet.hudson.test.Bug; +import org.jvnet.hudson.test.Issue; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; @@ -104,7 +104,7 @@ public void testRetrieveChecksumDifferent() throws Exception { } @Test - @Bug(39547) + @Issue("JENKINS-39547") public void retrieveInvalidChecksum() throws Exception { when(mockChannel.getProperty(JarLoader.THEIRS)).thenReturn(mockJarLoader); diff --git a/src/test/java/hudson/remoting/LauncherTest.java b/src/test/java/hudson/remoting/LauncherTest.java index 1cc0e6d2f..cedf5b43e 100644 --- a/src/test/java/hudson/remoting/LauncherTest.java +++ b/src/test/java/hudson/remoting/LauncherTest.java @@ -11,7 +11,8 @@ import java.io.IOException; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; public class LauncherTest { diff --git a/src/test/java/hudson/remoting/PipeTest.java b/src/test/java/hudson/remoting/PipeTest.java index 76a5b5d82..6944e3524 100644 --- a/src/test/java/hudson/remoting/PipeTest.java +++ b/src/test/java/hudson/remoting/PipeTest.java @@ -26,7 +26,7 @@ import junit.framework.Test; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; -import org.jvnet.hudson.test.Bug; +import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.For; import java.io.ByteArrayOutputStream; @@ -62,7 +62,7 @@ public void testRemoteWrite() throws Exception { * Have the reader close the read end of the pipe while the writer is still writing. * The writer should pick up a failure. */ - @Bug(8592) + @Issue("JENKINS-8592") @For(Pipe.class) public void testReaderCloseWhileWriterIsStillWriting() throws Exception { final Pipe p = Pipe.createRemoteToLocal(); @@ -145,7 +145,7 @@ public void testLocalWrite2() throws Exception { } public interface ISaturationTest { - void ensureConnected() throws IOException; + void ensureConnected(); int readFirst() throws IOException; void readRest() throws IOException; } @@ -201,7 +201,7 @@ public CreateSaturationTestProxy(Pipe pipe) { } @Override - public ISaturationTest call() throws IOException { + public ISaturationTest call() { return Channel.currentOrFail().export(ISaturationTest.class, new ISaturationTest() { private InputStream in; @Override @@ -289,7 +289,7 @@ public void testQuickBurstWrite() throws Exception { private static class DevNullSink extends CallableBase { @Override - public OutputStream call() throws IOException { + public OutputStream call() { return new RemoteOutputStream(new NullOutputStream()); } private static final long serialVersionUID = 1L; diff --git a/src/test/java/hudson/remoting/PrefetchingTest.java b/src/test/java/hudson/remoting/PrefetchingTest.java index 35b43fc18..b2e164440 100644 --- a/src/test/java/hudson/remoting/PrefetchingTest.java +++ b/src/test/java/hudson/remoting/PrefetchingTest.java @@ -237,7 +237,7 @@ public Void call() throws IOException { private class JarCacherCallable extends CallableBase { @Override - public Void call() throws IOException { + public Void call() { Channel.currentOrFail().setJarCache(new FileSystemJarCache(dir, true)); return null; } diff --git a/src/test/java/hudson/remoting/ProxyWriterTest.java b/src/test/java/hudson/remoting/ProxyWriterTest.java index 9514aabef..99d9c8cf4 100644 --- a/src/test/java/hudson/remoting/ProxyWriterTest.java +++ b/src/test/java/hudson/remoting/ProxyWriterTest.java @@ -1,7 +1,7 @@ package hudson.remoting; import junit.framework.Test; -import org.jvnet.hudson.test.Bug; +import org.jvnet.hudson.test.Issue; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -76,7 +76,7 @@ private static void writeBunchOfData(Writer w) throws IOException { /** * If {@link ProxyWriter} gets garbage collected, it should unexport the entry but shouldn't try to close the stream. */ - @Bug(20769) + @Issue("JENKINS-20769") public void testRemoteGC() throws InterruptedException, IOException { // in the legacy mode ProxyWriter will try to close the stream, so can't run this test if (channelRunner.getName().equals("local-compatibility")) @@ -166,7 +166,7 @@ public Void call() throws IOException { private static class GcCallable extends CallableBase { @Override - public Boolean call() throws IOException { + public Boolean call() { System.gc(); return W.get() == null; } diff --git a/src/test/java/hudson/remoting/TestLinkage.java b/src/test/java/hudson/remoting/TestLinkage.java index c22522a63..526a98f11 100644 --- a/src/test/java/hudson/remoting/TestLinkage.java +++ b/src/test/java/hudson/remoting/TestLinkage.java @@ -27,7 +27,7 @@ public class TestLinkage extends CallableBase { @Override - public Object call() throws Throwable { + public Object call() { // force classloading of several classes // when we run this test, we insert an artificial delay to each classloading // so that we can intercept the classloading. diff --git a/src/test/java/org/jenkinsci/remoting/engine/HostPortTest.java b/src/test/java/org/jenkinsci/remoting/engine/HostPortTest.java index 1abfdb87f..7253ebd03 100644 --- a/src/test/java/org/jenkinsci/remoting/engine/HostPortTest.java +++ b/src/test/java/org/jenkinsci/remoting/engine/HostPortTest.java @@ -3,7 +3,7 @@ import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; public class HostPortTest { diff --git a/src/test/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerTest.java b/src/test/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerTest.java index d0ca01f37..35b9a10de 100644 --- a/src/test/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerTest.java +++ b/src/test/java/org/jenkinsci/remoting/engine/JnlpProtocolHandlerTest.java @@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; @RunWith(Theories.class) diff --git a/src/test/java/org/jenkinsci/remoting/engine/WorkDirManagerTest.java b/src/test/java/org/jenkinsci/remoting/engine/WorkDirManagerTest.java index 1eadffcb2..5195f449e 100644 --- a/src/test/java/org/jenkinsci/remoting/engine/WorkDirManagerTest.java +++ b/src/test/java/org/jenkinsci/remoting/engine/WorkDirManagerTest.java @@ -50,7 +50,7 @@ import org.jenkinsci.remoting.engine.WorkDirManager.DirType; import org.junit.Assume; -import org.jvnet.hudson.test.Bug; +import org.jvnet.hudson.test.Issue; /** * Tests of {@link WorkDirManager} @@ -178,7 +178,7 @@ public void shouldNotSupportPathDelimitersAndSpacesInTheInternalDirName() throws } @Test - @Bug(39130) + @Issue("JENKINS-39130") public void shouldFailToStartupIf_WorkDir_IsMissing_andRequired() throws Exception { final File tmpDirFile = tmpDir.newFolder("foo"); final File workDir = new File(tmpDirFile, "just/a/long/non/existent/path"); @@ -188,7 +188,7 @@ public void shouldFailToStartupIf_WorkDir_IsMissing_andRequired() throws Excepti } @Test - @Bug(39130) + @Issue("JENKINS-39130") public void shouldFailToStartupIf_InternalDir_IsMissing_andRequired() throws Exception { // Create only the working directory, not the nested one final File tmpDirFile = tmpDir.newFolder("foo"); diff --git a/src/test/java/org/jenkinsci/remoting/nio/FifoBufferTest.java b/src/test/java/org/jenkinsci/remoting/nio/FifoBufferTest.java index 50541f0c9..a774515e4 100644 --- a/src/test/java/org/jenkinsci/remoting/nio/FifoBufferTest.java +++ b/src/test/java/org/jenkinsci/remoting/nio/FifoBufferTest.java @@ -6,7 +6,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; diff --git a/src/test/java/org/jenkinsci/remoting/protocol/IOHubTest.java b/src/test/java/org/jenkinsci/remoting/protocol/IOHubTest.java index d6c10014e..1fcbefd02 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/IOHubTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/IOHubTest.java @@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; public class IOHubTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackImplTest.java b/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackImplTest.java index 87ff6ac6b..869dacdc6 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackImplTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackImplTest.java @@ -62,7 +62,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; public class ProtocolStackImplTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackTest.java b/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackTest.java index d4472abe5..ce5d5198c 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/ProtocolStackTest.java @@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; public class ProtocolStackTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/cert/BlindTrustX509ExtendedTrustManagerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/cert/BlindTrustX509ExtendedTrustManagerTest.java index 36dfbfd42..941ba8dda 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/cert/BlindTrustX509ExtendedTrustManagerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/cert/BlindTrustX509ExtendedTrustManagerTest.java @@ -32,7 +32,7 @@ import org.junit.rules.RuleChain; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; public class BlindTrustX509ExtendedTrustManagerTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManagerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManagerTest.java index e7078c307..67c709b27 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManagerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/cert/PublicKeyMatchingX509ExtendedTrustManagerTest.java @@ -33,7 +33,7 @@ import org.junit.rules.RuleChain; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class PublicKeyMatchingX509ExtendedTrustManagerTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/cert/RSAKeyPairRule.java b/src/test/java/org/jenkinsci/remoting/protocol/cert/RSAKeyPairRule.java index 72d26d4ad..00dc76e04 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/cert/RSAKeyPairRule.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/cert/RSAKeyPairRule.java @@ -23,7 +23,6 @@ */ package org.jenkinsci.remoting.protocol.cert; -import java.security.InvalidAlgorithmParameterException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; diff --git a/src/test/java/org/jenkinsci/remoting/protocol/cert/ValidityCheckingX509ExtendedTrustManagerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/cert/ValidityCheckingX509ExtendedTrustManagerTest.java index 3e7c80067..88e4eaa07 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/cert/ValidityCheckingX509ExtendedTrustManagerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/cert/ValidityCheckingX509ExtendedTrustManagerTest.java @@ -33,7 +33,7 @@ import org.junit.rules.RuleChain; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class ValidityCheckingX509ExtendedTrustManagerTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/impl/AckFilterLayerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/impl/AckFilterLayerTest.java index 9f5d7b9d3..8370c9f35 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/impl/AckFilterLayerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/impl/AckFilterLayerTest.java @@ -49,7 +49,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; @RunWith(Theories.class) public class AckFilterLayerTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersFilterLayerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersFilterLayerTest.java index bb7d99a62..fb28ae23c 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersFilterLayerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersFilterLayerTest.java @@ -56,7 +56,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; @RunWith(Theories.class) diff --git a/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersTest.java b/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersTest.java index 45c298c3b..bd95553a8 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/impl/ConnectionHeadersTest.java @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; public class ConnectionHeadersTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/impl/NetworkLayerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/impl/NetworkLayerTest.java index 52b445731..110560683 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/impl/NetworkLayerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/impl/NetworkLayerTest.java @@ -43,7 +43,7 @@ import java.util.concurrent.Executors; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; @RunWith(Theories.class) public class NetworkLayerTest { diff --git a/src/test/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayerTest.java b/src/test/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayerTest.java index 8ee74600c..1c8b04083 100644 --- a/src/test/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayerTest.java +++ b/src/test/java/org/jenkinsci/remoting/protocol/impl/SSLEngineFilterLayerTest.java @@ -62,7 +62,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; @RunWith(Theories.class) public class SSLEngineFilterLayerTest { diff --git a/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueInputStreamTest.java b/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueInputStreamTest.java index 499f88462..026dc8abf 100644 --- a/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueInputStreamTest.java +++ b/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueInputStreamTest.java @@ -32,7 +32,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assume.assumeThat; public class ByteBufferQueueInputStreamTest { diff --git a/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueOutputStreamTest.java b/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueOutputStreamTest.java index 93c9802f7..ae9579b37 100644 --- a/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueOutputStreamTest.java +++ b/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueOutputStreamTest.java @@ -29,7 +29,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class ByteBufferQueueOutputStreamTest { @Test diff --git a/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueTest.java b/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueTest.java index 4d8f186e9..36c691a4d 100644 --- a/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueTest.java +++ b/src/test/java/org/jenkinsci/remoting/util/ByteBufferQueueTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class ByteBufferQueueTest { diff --git a/src/test/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStreamTest.java b/src/test/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStreamTest.java index 69b12695a..034b6efbe 100644 --- a/src/test/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStreamTest.java +++ b/src/test/java/org/jenkinsci/remoting/util/FastByteBufferQueueInputStreamTest.java @@ -32,7 +32,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class FastByteBufferQueueInputStreamTest { @Test diff --git a/src/test/java/org/jenkinsci/remoting/util/SettableFutureTest.java b/src/test/java/org/jenkinsci/remoting/util/SettableFutureTest.java index 3cf04922a..0a7d4e05e 100644 --- a/src/test/java/org/jenkinsci/remoting/util/SettableFutureTest.java +++ b/src/test/java/org/jenkinsci/remoting/util/SettableFutureTest.java @@ -39,7 +39,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail;