diff --git a/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/async/RedirectedAsyncOperation.java b/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/async/RedirectedAsyncOperation.java index 0063ec0e990c..49f7ae24abda 100644 --- a/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/async/RedirectedAsyncOperation.java +++ b/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/async/RedirectedAsyncOperation.java @@ -7,15 +7,15 @@ public abstract class RedirectedAsyncOperation implements AsyncOperation { protected final AsyncOperation source; - private final AsyncOperationListenImpl listenImpl; + private AsyncOperationListenImpl listenImpl; public RedirectedAsyncOperation(AsyncOperation source) { this.source = source; + } + + void listen() { this.listenImpl = new AsyncOperationListenImpl<>(this); - source.register(new AsyncCallback() { - @Override - public void done(AsyncOperation op) { notifyDone(); } - }); + source.register(op -> notifyDone()); } private void notifyDone() { diff --git a/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResult.java b/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResult.java index f62c97696ba8..eae8fb8ba324 100644 --- a/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResult.java +++ b/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResult.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -public class JsonHttpResult extends HttpResult { +public final class JsonHttpResult extends HttpResult { private static final ObjectMapper mapper = new ObjectMapper(); diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java index 1a5ce12be923..1f5351302011 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/async/AsyncTest.java @@ -103,12 +103,13 @@ public void done(AsyncOperation op) { void testRedirectedOperation() { { final AsyncOperationImpl op = new AsyncOperationImpl<>("test", "desc"); - AsyncOperation deleteRequest = new RedirectedAsyncOperation(op) { + var deleteRequest = new RedirectedAsyncOperation(op) { @Override public Integer getResult() { return Integer.valueOf(op.getResult()); } }; + deleteRequest.listen(); final LinkedList result = new LinkedList<>(); deleteRequest.register(new AsyncCallback() { @Override @@ -134,12 +135,13 @@ public void done(AsyncOperation op) { } { final AsyncOperationImpl op = new AsyncOperationImpl<>("test", "desc"); - AsyncOperation deleteRequest = new RedirectedAsyncOperation(op) { + var deleteRequest = new RedirectedAsyncOperation(op) { @Override public Integer getResult() { return Integer.valueOf(op.getResult()); } }; + deleteRequest.listen(); op.setFailure(new Exception("foo")); assertTrue(deleteRequest.isDone()); assertEquals("foo", deleteRequest.getCause().getMessage()); @@ -182,7 +184,7 @@ public void successfullyDone(AsyncOperation source) { } } - private abstract class StressThread implements Runnable { + private abstract static class StressThread implements Runnable { private final Object monitor; private boolean running = true; @@ -210,20 +212,20 @@ public void run() { public abstract void doTask(); } - private abstract class AsyncOpStressThread extends StressThread { + private abstract static class AsyncOpStressThread extends StressThread { public AsyncOperationImpl op; public AsyncOpStressThread(Object monitor) { super(monitor); } @Override public boolean hasTask() { return op != null; } } - private class Completer extends AsyncOpStressThread { + private static class Completer extends AsyncOpStressThread { public Completer(Object monitor) { super(monitor); } @Override public void doTask() { op.setResult("foo"); op = null; } } - private class Listener extends AsyncOpStressThread implements AsyncCallback { + private static class Listener extends AsyncOpStressThread implements AsyncCallback { int counter = 0; int unset = 0; int priorReg = 0; diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/DataplaneProxyService.java b/container-disc/src/main/java/com/yahoo/container/jdisc/DataplaneProxyService.java index e1a753ddf275..71b9ad542b78 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/DataplaneProxyService.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/DataplaneProxyService.java @@ -23,7 +23,7 @@ * * @author mortent */ -public class DataplaneProxyService extends AbstractComponent { +public final class DataplaneProxyService extends AbstractComponent { private static final Logger logger = Logger.getLogger(DataplaneProxyService.class.getName()); private static final String PREFIX = "/opt/vespa";