Skip to content

Commit

Permalink
Merge pull request #388 from basil/override
Browse files Browse the repository at this point in the history
Add missing override annotations
  • Loading branch information
jeffret-b authored Jul 6, 2020
2 parents d32131f + 6d52119 commit cff197b
Show file tree
Hide file tree
Showing 90 changed files with 367 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public interface ByteArrayReceiver {
public final void setup(final Channel channel, final CommandReceiver receiver) {
this.channel = channel;
setup(new ByteArrayReceiver() {
@Override
public void handle(byte[] payload) {
try {
Command cmd = Command.readFrom(channel, payload);
Expand All @@ -68,6 +69,7 @@ public void handle(byte[] payload) {
}
}

@Override
public void terminate(IOException e) {
receiver.terminate(e);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/hudson/remoting/AsyncFutureImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,22 @@ public AsyncFutureImpl(Throwable value) {
set(value);
}

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}

@Override
public synchronized boolean isCancelled() {
return cancelled;
}

@Override
public synchronized boolean isDone() {
return completed;
}

@Override
public synchronized V get() throws InterruptedException, ExecutionException {
while(!completed)
wait();
Expand All @@ -80,6 +84,7 @@ public synchronized V get() throws InterruptedException, ExecutionException {
return value;
}

@Override
@CheckForNull
public synchronized V get(@Nonnegative long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
// The accuracy of wait(long) operation is milliseconds anyway, but ok.
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/hudson/remoting/AtmostOneThreadExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public AtmostOneThreadExecutor() {
this(new DaemonThreadFactory());
}

@Override
public void shutdown() {
synchronized (q) {
shutdown = true;
Expand All @@ -54,6 +55,7 @@ private boolean isAlive() {
return worker!=null && worker.isAlive();
}

@Override
public List<Runnable> shutdownNow() {
synchronized (q) {
shutdown = true;
Expand All @@ -63,14 +65,17 @@ public List<Runnable> shutdownNow() {
}
}

@Override
public boolean isShutdown() {
return shutdown;
}

@Override
public boolean isTerminated() {
return shutdown && !isAlive();
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
synchronized (q) {
long now = System.nanoTime();
Expand All @@ -83,6 +88,7 @@ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedE
return isTerminated();
}

@Override
public void execute(Runnable command) {
synchronized (q) {
if (isShutdown()) {
Expand All @@ -98,6 +104,7 @@ public void execute(Runnable command) {
}

private class Worker implements Runnable {
@Override
public void run() {
while (true) {
Runnable task;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/hudson/remoting/BinarySafeStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static InputStream wrap(InputStream in) {
final byte[] qualtet = new byte[4];
int input = 0;

@Override
public int read() throws IOException {
if(remaining==0) {
remaining = _read(triplet,0,3);
Expand All @@ -87,6 +88,7 @@ public int read() throws IOException {
return ((int) triplet[3 - remaining--]) & 0xFF;
}

@Override
public int read(byte b[], int off, int len) throws IOException {
if(remaining==-1) return -1; // EOF

Expand Down Expand Up @@ -209,6 +211,7 @@ private int _read(byte b[], int off, int len) throws IOException {
return totalRead;
}

@Override
public int available() throws IOException {
// roughly speaking we got 3/4 of the underlying available bytes
return super.available()*3/4;
Expand All @@ -228,6 +231,7 @@ public static OutputStream wrap(OutputStream out) {
private int remaining=0;
private final byte[] out = new byte[4];

@Override
public void write(int b) throws IOException {
if(remaining==2) {
_write(triplet[0],triplet[1],(byte)b);
Expand All @@ -237,6 +241,7 @@ public void write(int b) throws IOException {
}
}

@Override
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) {
Expand Down Expand Up @@ -272,6 +277,7 @@ private void _write(byte a, byte b, byte c) throws IOException {
super.out.write(out,0,4);
}

@Override
public void flush() throws IOException {
int a = triplet[0];
int b = triplet[1];
Expand Down
1 change: 1 addition & 0 deletions src/main/java/hudson/remoting/CallableDecoratorList.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <V> java.util.concurrent.Callable<V> wrapCallable(java.util.concurrent.Callable<

private <V> java.util.concurrent.Callable<V> applyDecorator(final java.util.concurrent.Callable<V> inner, final CallableDecorator filter) {
return new java.util.concurrent.Callable<V>() {
@Override
public V call() throws Exception {
return filter.call(inner);
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/hudson/remoting/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ protected Channel(@Nonnull ChannelBuilder settings, @Nonnull CommandTransport tr
this.properties.putAll(settings.getProperties());

transport.setup(this, new CommandReceiver() {
@Override
public void handle(Command cmd) {
commandsReceived++;
long receivedAt = System.currentTimeMillis();
Expand All @@ -615,6 +616,7 @@ public void handle(Command cmd) {
}
}

@Override
public void terminate(IOException e) {
Channel.this.terminate(e);
}
Expand Down Expand Up @@ -983,6 +985,7 @@ public void setJarCache(@Nonnull JarCache jarCache) {
/**
* {@inheritDoc}
*/
@Override
public <V,T extends Throwable>
V call(Callable<V,T> callable) throws IOException, T, InterruptedException {
if (isClosingOrClosed()) {
Expand Down Expand Up @@ -1017,6 +1020,7 @@ V call(Callable<V,T> callable) throws IOException, T, InterruptedException {
/**
* {@inheritDoc}
*/
@Override
public <V,T extends Throwable>
Future<V> callAsync(final Callable<V,T> callable) throws IOException {
if (isClosingOrClosed()) {
Expand Down Expand Up @@ -1173,6 +1177,7 @@ public void removeLocalExecutionInterceptor(CallableFilter filter) {
* @throws InterruptedException
* If the current thread is interrupted while waiting for the completion.
*/
@Override
public synchronized void join() throws InterruptedException {
while(inClosed==null || outClosed==null)
// not that I really encountered any situation where this happens, but
Expand Down Expand Up @@ -1267,6 +1272,7 @@ private static final class SetMaximumBytecodeLevel implements Callable<Void,Runt
SetMaximumBytecodeLevel(short level) {
this.level = level;
}
@Override
public Void call() throws RuntimeException {
Channel.currentOrFail().maximumBytecodeLevel = level;
return null;
Expand All @@ -1287,6 +1293,7 @@ public void checkRoles(RoleChecker checker) throws SecurityException {
* If the current thread is interrupted while waiting for the completion.
* @since 1.299
*/
@Override
public synchronized void join(long timeout) throws InterruptedException {
long now = System.nanoTime();
long end = now + TimeUnit.MILLISECONDS.toNanos(timeout);
Expand All @@ -1308,6 +1315,7 @@ private CloseCommand(Channel channel, @CheckForNull Throwable cause) {
super(channel, cause);
}

@Override
protected void execute(Channel channel) {
try {
channel.close();
Expand Down Expand Up @@ -1442,6 +1450,7 @@ public void dumpDiagnostics(@Nonnull PrintWriter w) throws IOException {
/**
* {@inheritDoc}
*/
@Override
public void close() throws IOException {
close(null);
}
Expand Down Expand Up @@ -1535,6 +1544,7 @@ public <T> T getProperty(ChannelProperty<T> key) {
* to wait for the set by the other side of the channel (via {@link #waitForRemoteProperty(Object)}.
* If we don't abort after the channel shutdown, this method will block forever.
*/
@Override
@Nonnull
public Object waitForProperty(@Nonnull Object key) throws InterruptedException {

Expand Down Expand Up @@ -1743,13 +1753,15 @@ public void syncIO() throws IOException, InterruptedException {
// callAsync(new IOSyncer());
// }

@Override
public void syncLocalIO() throws InterruptedException {
Thread t = Thread.currentThread();
String old = t.getName();
t.setName("I/O sync: "+old);
try {
// no one waits for the completion of this Runnable, so not using I/O ID
pipeWriter.submit(0,new Runnable() {
@Override
public void run() {
// noop
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/hudson/remoting/ClassicCommandTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Capability getRemoteCapability() throws IOException {
return remoteCapability;
}

@Override
public final void write(Command cmd, boolean last) throws IOException {
cmd.writeTo(channel,oos);
// TODO notifyWrite using CountingOutputStream
Expand All @@ -62,10 +63,12 @@ public final void write(Command cmd, boolean last) throws IOException {
oos.reset();
}

@Override
public void closeWrite() throws IOException {
oos.close();
}

@Override
public final Command read() throws IOException, ClassNotFoundException {
try {
Command cmd = Command.readFromObjectStream(channel, ois);
Expand Down Expand Up @@ -95,6 +98,7 @@ private StreamCorruptedException diagnoseStreamCorruption(Exception e) throws St
return rawIn.analyzeCrash(e,(channel!=null ? channel : this).toString());
}

@Override
public void closeRead() throws IOException {
ois.close();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/hudson/remoting/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ private Source(@CheckForNull Throwable cause) {
super(cause);
}

@Override
public String toString() {
return "Command "+Command.this.toString()+" created at";
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/hudson/remoting/DaemonThreadFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class DaemonThreadFactory implements ThreadFactory {
private static final Logger LOGGER = Logger.getLogger(DaemonThreadFactory.class.getName());

@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setDaemon(true);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/hudson/remoting/DelegatingExecutorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,67 @@ public DelegatingExecutorService(ExecutorService base) {
this.base = base;
}

@Override
public void shutdown() {
base.shutdown();
}

@Override
public List<Runnable> shutdownNow() {
return base.shutdownNow();
}

@Override
public boolean isShutdown() {
return base.isShutdown();
}

@Override
public boolean isTerminated() {
return base.isTerminated();
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
return base.awaitTermination(timeout, unit);
}

@Override
public <T> Future<T> submit(Callable<T> task) {
return base.submit(task);
}

@Override
public <T> Future<T> submit(Runnable task, T result) {
return base.submit(task, result);
}

@Override
public Future<?> submit(Runnable task) {
return base.submit(task);
}

@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
return base.invokeAll(tasks);
}

@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
return base.invokeAll(tasks, timeout, unit);
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
return base.invokeAny(tasks);
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
return base.invokeAny(tasks, timeout, unit);
}

@Override
public void execute(Runnable command) {
base.execute(command);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/hudson/remoting/DumbClassLoaderBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ class DumbClassLoaderBridge implements IClassLoader {
this.base = base;
}

@Override
public byte[] fetchJar(URL url) throws IOException {
return base.fetchJar(url);
}

@Override
public byte[] fetch(String className) throws ClassNotFoundException {
return base.fetch(className);
}

@Override
public ClassFile fetch2(String className) throws ClassNotFoundException {
return base.fetch2(className);
}
Expand All @@ -53,6 +56,7 @@ public byte[][] getResources(String name) throws IOException {
return base.getResources(name);
}

@Override
public Map<String,ClassFile2> fetch3(String className) throws ClassNotFoundException {
ClassFile cf = fetch2(className);
return Collections.singletonMap(className,
Expand Down
Loading

0 comments on commit cff197b

Please sign in to comment.