diff --git a/container-messagebus/src/main/java/com/yahoo/messagebus/jdisc/MbusRequest.java b/container-messagebus/src/main/java/com/yahoo/messagebus/jdisc/MbusRequest.java index 8bdc9368c9f9..16ffbbed3c11 100644 --- a/container-messagebus/src/main/java/com/yahoo/messagebus/jdisc/MbusRequest.java +++ b/container-messagebus/src/main/java/com/yahoo/messagebus/jdisc/MbusRequest.java @@ -6,6 +6,7 @@ import com.yahoo.messagebus.Message; import java.net.URI; +import java.util.Objects; /** * @author Simon Thoresen Hult @@ -18,24 +19,21 @@ public MbusRequest(CurrentContainer current, URI uri, Message msg) { this(current, uri, msg, true); } public MbusRequest(CurrentContainer current, URI uri, Message msg, boolean isServerRequest) { - super(current, uri, isServerRequest); - this.message = validateMessage(msg); + super(current, validateParams(msg, uri), isServerRequest); + this.message = msg; } public MbusRequest(Request parent, URI uri, Message msg) { - super(parent, uri); - this.message = validateMessage(msg); + super(parent, validateParams(msg, uri)); + this.message = msg; } public Message getMessage() { return message; } - private Message validateMessage(Message msg) { - if (msg != null) { - return msg; - } - release(); - throw new NullPointerException(); + private static URI validateParams(Message msg, URI uri) { + Objects.requireNonNull(msg, "msg cannot be null"); + return uri; } } diff --git a/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedIntermediateSession.java b/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedIntermediateSession.java index 2283f703463b..cbb805898ebd 100644 --- a/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedIntermediateSession.java +++ b/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedIntermediateSession.java @@ -21,7 +21,7 @@ /** * @author Simon Thoresen Hult */ -public class SharedIntermediateSession extends AbstractResource +public final class SharedIntermediateSession extends AbstractResource implements ClientSession, ServerSession, MessageHandler, ReplyHandler { diff --git a/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedSourceSession.java b/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedSourceSession.java index 673af5e05a21..36f02b1226a2 100644 --- a/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedSourceSession.java +++ b/container-messagebus/src/main/java/com/yahoo/messagebus/shared/SharedSourceSession.java @@ -16,7 +16,7 @@ /** * @author Simon Thoresen Hult */ -public class SharedSourceSession extends AbstractResource implements ClientSession, ReplyHandler { +public final class SharedSourceSession extends AbstractResource implements ClientSession, ReplyHandler { private static final Logger log = Logger.getLogger(SharedSourceSession.class.getName()); private final SourceSession session; diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java index 354c718dcf60..2ef17535bc67 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java @@ -37,7 +37,7 @@ * * @author gjoranv */ -public class ApplicationMetricsRetriever extends AbstractComponent implements Runnable { +public final class ApplicationMetricsRetriever extends AbstractComponent implements Runnable { private static final Logger log = Logger.getLogger(ApplicationMetricsRetriever.class.getName()); diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java index d51b5554ea91..d403ce5b8e0d 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcConnector.java @@ -20,7 +20,7 @@ * * @author gjoranv */ -public class RpcConnector extends AbstractComponent { +public final class RpcConnector extends AbstractComponent { private static final Logger log = Logger.getLogger(RpcConnector.class.getName()); private final Supervisor supervisor; diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcServer.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcServer.java index 671e91721947..1415ecd4ce8e 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcServer.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/rpc/RpcServer.java @@ -34,7 +34,7 @@ * * @author gjoranv */ -public class RpcServer { +public final class RpcServer { private static final Logger log = Logger.getLogger(RpcServer.class.getName()); diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/MockHttpServer.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/MockHttpServer.java index 75b55c691ffb..3e070f9d5069 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/MockHttpServer.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/service/MockHttpServer.java @@ -12,7 +12,7 @@ /** * @author jobergum */ -public class MockHttpServer { +public final class MockHttpServer { private String response; private final HttpServer server; diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java index f86ccc3df18e..51e48fd7dcb9 100644 --- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java +++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java @@ -44,7 +44,7 @@ * @author oyving * @author mpolden */ -public class RoutingGenerator extends AbstractComponent { +public final class RoutingGenerator extends AbstractComponent { private static final Logger log = Logger.getLogger(RoutingGenerator.class.getName()); private static final Duration configTimeout = Duration.ofSeconds(10); diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java index 93ea68e0154d..f6cf8cea1714 100644 --- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java +++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java @@ -40,7 +40,7 @@ * @author mortent * @author mpolden */ -public class NginxMetricsReporter extends AbstractComponent implements Runnable { +public final class NginxMetricsReporter extends AbstractComponent implements Runnable { private static final Duration interval = Duration.ofSeconds(20); diff --git a/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/mock/HttpClientMock.java b/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/mock/HttpClientMock.java index b323c1bf6460..4c8bd55b8d81 100644 --- a/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/mock/HttpClientMock.java +++ b/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/mock/HttpClientMock.java @@ -60,7 +60,7 @@ private static String requestKey(String method, String url) { return method.toUpperCase(Locale.ENGLISH) + " " + url; } - public static class JsonResponse extends BasicHttpResponse implements CloseableHttpResponse { + public static final class JsonResponse extends BasicHttpResponse implements CloseableHttpResponse { public JsonResponse(Path jsonFile, int code) { this(Exceptions.uncheck(() -> Files.readString(jsonFile)), code);