This is an automated email from the ASF dual-hosted git repository. mapohl pushed a commit to branch release-1.16 in repository https://gitbox.apache.org/repos/asf/flink.git
commit 56d1296df7de20a44c1ca254e02587606a5facdb Author: Patrick Lucas <[email protected]> AuthorDate: Thu Jul 27 10:03:32 2023 +0200 [hotfix][rest] Expose fields with getters for testing Previously, these fields were package-private, non-final, and annotated with `@VisibleForTesting`. This change makes them private final and adds `@VisibleForTesting`-annotated getters for consistency with other fields. --- .../org/apache/flink/runtime/rest/RestClient.java | 7 ++++++- .../flink/runtime/rest/RestServerEndpoint.java | 7 ++++++- .../runtime/rest/RestExternalHandlersITCase.java | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java index bab7b6d4c72..b2b6f8a8dba 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java @@ -131,7 +131,7 @@ public class RestClient implements AutoCloseableAsync { private final Collection<CompletableFuture<Channel>> responseChannelFutures = ConcurrentHashMap.newKeySet(); - @VisibleForTesting List<OutboundChannelHandlerFactory> outboundChannelHandlerFactories; + private final List<OutboundChannelHandlerFactory> outboundChannelHandlerFactories; public RestClient(Configuration configuration, Executor executor) throws ConfigurationException { @@ -245,6 +245,11 @@ public class RestClient implements AutoCloseableAsync { return responseChannelFutures; } + @VisibleForTesting + List<OutboundChannelHandlerFactory> getOutboundChannelHandlerFactories() { + return outboundChannelHandlerFactories; + } + @Override public CompletableFuture<Void> closeAsync() { return shutdownInternally(Time.seconds(10L)); diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java index ca72337307a..004cb8106ec 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java @@ -109,7 +109,7 @@ public abstract class RestServerEndpoint implements RestService { private State state = State.CREATED; - @VisibleForTesting List<InboundChannelHandlerFactory> inboundChannelHandlerFactories; + private final List<InboundChannelHandlerFactory> inboundChannelHandlerFactories; public RestServerEndpoint(Configuration configuration) throws IOException, ConfigurationException { @@ -152,6 +152,11 @@ public abstract class RestServerEndpoint implements RestService { Comparator.comparingInt(InboundChannelHandlerFactory::priority).reversed()); } + @VisibleForTesting + List<InboundChannelHandlerFactory> getInboundChannelHandlerFactories() { + return inboundChannelHandlerFactories; + } + /** * This method is called at the beginning of {@link #start()} to setup all handlers that the * REST server endpoint implementation requires. diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestExternalHandlersITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestExternalHandlersITCase.java index f950b5c1573..680baa0211f 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestExternalHandlersITCase.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestExternalHandlersITCase.java @@ -46,6 +46,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledExecutorService; @@ -122,21 +123,23 @@ public class RestExternalHandlersITCase extends TestLogger { } @Test - void testHandlersMustBeLoaded() throws Exception { - assertEquals(serverEndpoint.inboundChannelHandlerFactories.size(), 2); + void testHandlersMustBeLoaded() { + final List<InboundChannelHandlerFactory> inboundChannelHandlerFactories = + serverEndpoint.getInboundChannelHandlerFactories(); + assertEquals(inboundChannelHandlerFactories.size(), 2); assertTrue( - serverEndpoint.inboundChannelHandlerFactories.get(0) - instanceof Prio1InboundChannelHandlerFactory); + inboundChannelHandlerFactories.get(0) instanceof Prio1InboundChannelHandlerFactory); assertTrue( - serverEndpoint.inboundChannelHandlerFactories.get(1) - instanceof Prio0InboundChannelHandlerFactory); + inboundChannelHandlerFactories.get(1) instanceof Prio0InboundChannelHandlerFactory); - assertEquals(restClient.outboundChannelHandlerFactories.size(), 2); + final List<OutboundChannelHandlerFactory> outboundChannelHandlerFactories = + restClient.getOutboundChannelHandlerFactories(); + assertEquals(outboundChannelHandlerFactories.size(), 2); assertTrue( - restClient.outboundChannelHandlerFactories.get(0) + outboundChannelHandlerFactories.get(0) instanceof Prio1OutboundChannelHandlerFactory); assertTrue( - restClient.outboundChannelHandlerFactories.get(1) + outboundChannelHandlerFactories.get(1) instanceof Prio0OutboundChannelHandlerFactory); try {
