From 3684280b8c844242b44894cd84e670ae0cd71df1 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Tue, 31 Jan 2023 21:39:31 -0800 Subject: [PATCH 01/11] Use stub channel instead of interceptedChannel for getStream --- .../src/main/java/org/apache/arrow/flight/FlightClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java index 1f50f50a293f..80dcb64a6878 100644 --- a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java +++ b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java @@ -306,8 +306,9 @@ public SchemaResult getSchema(FlightDescriptor descriptor, CallOption... options * @param options RPC-layer hints for this call. */ public FlightStream getStream(Ticket ticket, CallOption... options) { - final io.grpc.CallOptions callOptions = CallOptions.wrapStub(asyncStub, options).getCallOptions(); - ClientCall call = interceptedChannel.newCall(doGetDescriptor, callOptions); + FlightServiceStub stub = CallOptions.wrapStub(asyncStub, options); + final io.grpc.CallOptions callOptions = stub.getCallOptions(); + ClientCall call = stub.getChannel().newCall(doGetDescriptor, callOptions); FlightStream stream = new FlightStream( allocator, PENDING_REQUESTS, From ccd14bfefee29916c38926a31b91d158019e6409 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Tue, 31 Jan 2023 22:01:57 -0800 Subject: [PATCH 02/11] Replace all interceptedChannel uses with the stub channel --- .../java/org/apache/arrow/flight/FlightClient.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java index 80dcb64a6878..1b2508618454 100644 --- a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java +++ b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java @@ -79,7 +79,7 @@ public class FlightClient implements AutoCloseable { private static final int MAX_CHANNEL_TRACE_EVENTS = 0; private final BufferAllocator allocator; private final ManagedChannel channel; - private final Channel interceptedChannel; + private final FlightServiceBlockingStub blockingStub; private final FlightServiceStub asyncStub; private final ClientAuthInterceptor authInterceptor = new ClientAuthInterceptor(); @@ -101,7 +101,7 @@ public class FlightClient implements AutoCloseable { interceptors = new ClientInterceptor[]{authInterceptor, new ClientInterceptorAdapter(middleware)}; // Create a channel with interceptors pre-applied for DoGet and DoPut - this.interceptedChannel = ClientInterceptors.intercept(channel, interceptors); + Channel interceptedChannel = ClientInterceptors.intercept(channel, interceptors); blockingStub = FlightServiceGrpc.newBlockingStub(interceptedChannel); asyncStub = FlightServiceGrpc.newStub(interceptedChannel); @@ -255,13 +255,14 @@ public ClientStreamListener startPut(FlightDescriptor descriptor, PutListener me CallOption... options) { Preconditions.checkNotNull(descriptor, "descriptor must not be null"); Preconditions.checkNotNull(metadataListener, "metadataListener must not be null"); - final io.grpc.CallOptions callOptions = CallOptions.wrapStub(asyncStub, options).getCallOptions(); + FlightServiceStub stub = CallOptions.wrapStub(asyncStub, options); + final io.grpc.CallOptions callOptions = stub.getCallOptions(); try { final SetStreamObserver resultObserver = new SetStreamObserver(allocator, metadataListener); ClientCallStreamObserver observer = (ClientCallStreamObserver) ClientCalls.asyncBidiStreamingCall( - interceptedChannel.newCall(doPutDescriptor, callOptions), resultObserver); + stub.getChannel().newCall(doPutDescriptor, callOptions), resultObserver); return new PutObserver( descriptor, observer, metadataListener::isCancelled, metadataListener::getResult); } catch (StatusRuntimeException sre) { @@ -354,10 +355,11 @@ public void onCompleted() { */ public ExchangeReaderWriter doExchange(FlightDescriptor descriptor, CallOption... options) { Preconditions.checkNotNull(descriptor, "descriptor must not be null"); - final io.grpc.CallOptions callOptions = CallOptions.wrapStub(asyncStub, options).getCallOptions(); + FlightServiceStub stub = CallOptions.wrapStub(asyncStub, options); + final io.grpc.CallOptions callOptions = stub.getCallOptions(); try { - final ClientCall call = interceptedChannel.newCall(doExchangeDescriptor, callOptions); + final ClientCall call = stub.getChannel().newCall(doExchangeDescriptor, callOptions); final FlightStream stream = new FlightStream(allocator, PENDING_REQUESTS, call::cancel, call::request); final ClientCallStreamObserver observer = (ClientCallStreamObserver) ClientCalls.asyncBidiStreamingCall(call, stream.asObserver()); From d313ec612c0d3a1c0756ca7dc4476f38dce49726 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Tue, 31 Jan 2023 22:28:55 -0800 Subject: [PATCH 03/11] Fix deprecated call --- .../src/main/java/org/apache/arrow/flight/HeaderCallOption.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/HeaderCallOption.java b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/HeaderCallOption.java index e2fad1a402de..1a04ca3d0853 100644 --- a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/HeaderCallOption.java +++ b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/HeaderCallOption.java @@ -47,6 +47,6 @@ public HeaderCallOption(CallHeaders headers) { @Override public > T wrapStub(T stub) { - return MetadataUtils.attachHeaders(stub, propertiesMetadata); + return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(propertiesMetadata)); } } From 381ae08512bc8a3fd6543843560722b9934b52d9 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Fri, 24 Feb 2023 23:35:48 +0000 Subject: [PATCH 04/11] Ensure custom headers get sent on all async stub calls --- .../org/apache/arrow/flight/FlightClient.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java index 1b2508618454..8cf2bbaf2536 100644 --- a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java +++ b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightClient.java @@ -255,14 +255,12 @@ public ClientStreamListener startPut(FlightDescriptor descriptor, PutListener me CallOption... options) { Preconditions.checkNotNull(descriptor, "descriptor must not be null"); Preconditions.checkNotNull(metadataListener, "metadataListener must not be null"); - FlightServiceStub stub = CallOptions.wrapStub(asyncStub, options); - final io.grpc.CallOptions callOptions = stub.getCallOptions(); try { + final ClientCall call = asyncStubNewCall(doPutDescriptor, options); final SetStreamObserver resultObserver = new SetStreamObserver(allocator, metadataListener); ClientCallStreamObserver observer = (ClientCallStreamObserver) - ClientCalls.asyncBidiStreamingCall( - stub.getChannel().newCall(doPutDescriptor, callOptions), resultObserver); + ClientCalls.asyncBidiStreamingCall(call, resultObserver); return new PutObserver( descriptor, observer, metadataListener::isCancelled, metadataListener::getResult); } catch (StatusRuntimeException sre) { @@ -307,9 +305,7 @@ public SchemaResult getSchema(FlightDescriptor descriptor, CallOption... options * @param options RPC-layer hints for this call. */ public FlightStream getStream(Ticket ticket, CallOption... options) { - FlightServiceStub stub = CallOptions.wrapStub(asyncStub, options); - final io.grpc.CallOptions callOptions = stub.getCallOptions(); - ClientCall call = stub.getChannel().newCall(doGetDescriptor, callOptions); + final ClientCall call = asyncStubNewCall(doGetDescriptor, options); FlightStream stream = new FlightStream( allocator, PENDING_REQUESTS, @@ -355,11 +351,9 @@ public void onCompleted() { */ public ExchangeReaderWriter doExchange(FlightDescriptor descriptor, CallOption... options) { Preconditions.checkNotNull(descriptor, "descriptor must not be null"); - FlightServiceStub stub = CallOptions.wrapStub(asyncStub, options); - final io.grpc.CallOptions callOptions = stub.getCallOptions(); try { - final ClientCall call = stub.getChannel().newCall(doExchangeDescriptor, callOptions); + final ClientCall call = asyncStubNewCall(doExchangeDescriptor, options); final FlightStream stream = new FlightStream(allocator, PENDING_REQUESTS, call::cancel, call::request); final ClientCallStreamObserver observer = (ClientCallStreamObserver) ClientCalls.asyncBidiStreamingCall(call, stream.asObserver()); @@ -726,4 +720,14 @@ public FlightClient build() { return new FlightClient(allocator, builder.build(), middleware); } } + + /** + * Helper method to create a call from the asyncStub, method descriptor, and list of calling options. + */ + private ClientCall asyncStubNewCall( + MethodDescriptor descriptor, + CallOption... options) { + FlightServiceStub wrappedStub = CallOptions.wrapStub(asyncStub, options); + return wrappedStub.getChannel().newCall(descriptor, wrappedStub.getCallOptions()); + } } From 8de0537c725b20c78244b70bf70f10de38dff389 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Fri, 24 Feb 2023 23:38:11 +0000 Subject: [PATCH 05/11] Add unit tests for custom headers --- .../arrow/flight/client/CustomHeaderTest.java | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java new file mode 100644 index 000000000000..89587beda12d --- /dev/null +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -0,0 +1,204 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.arrow.flight.client; + +import java.util.*; + +import org.apache.arrow.flight.*; +import org.apache.arrow.flight.FlightClient.ClientStreamListener; +import org.apache.arrow.memory.BufferAllocator; +import org.apache.arrow.memory.RootAllocator; +import org.apache.arrow.util.AutoCloseables; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +/** + * Tests to ensure custom headers are passed along to the server for each command + */ +public class CustomHeaderTest { + FlightServer server; + FlightClient client; + BufferAllocator allocator; + TestCustomHeaderMiddleware.Factory headersMiddleware; + HeaderCallOption headers; + Map testHeaders = Map.of( + "foo", "bar", + "bar", "foo", + "answer", "42" + ); + + @Before + public void setUp() throws Exception { + allocator = new RootAllocator(Integer.MAX_VALUE); + headersMiddleware = new TestCustomHeaderMiddleware.Factory(); + FlightCallHeaders callHeaders = new FlightCallHeaders(); + for (Map.Entry entry : testHeaders.entrySet()) { + callHeaders.insert(entry.getKey(), entry.getValue()); + } + headers = new HeaderCallOption(callHeaders); + server = FlightTestUtil.getStartedServer( + location -> FlightServer.builder(allocator, location, new NoOpFlightProducer()) + .middleware(FlightServerMiddleware.Key.of("customHeader"), headersMiddleware) + .build() + ); + client = FlightClient.builder(allocator, server.getLocation()).build(); + } + + @After + public void tearDown() throws Exception { + allocator.getChildAllocators().forEach(BufferAllocator::close); + AutoCloseables.close(allocator, server, client); + } + + @Test + public void testHandshake() { + try { + client.handshake(headers); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.HANDSHAKE); + } + + @Test + public void testGetSchema() { + try { + client.getSchema(FlightDescriptor.command(new byte[0]), headers); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.GET_SCHEMA); + } + + @Test + public void testGetFlightInfo() { + try { + client.getInfo(FlightDescriptor.command(new byte[0]), headers); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.GET_FLIGHT_INFO); + } + + @Test + public void testListActions() { + try { + client.listActions(headers).iterator().next(); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.LIST_ACTIONS); + } + + @Test + public void testListFlights() { + try { + client.listFlights(new Criteria(new byte[]{1}), headers).iterator().next(); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.LIST_FLIGHTS); + } + + @Test + public void testDoAction() { + try { + client.doAction(new Action("test"), headers).next(); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.DO_ACTION); + } + + @Test + public void testStartPut() { + try { + final ClientStreamListener listener = client.startPut(FlightDescriptor.command(new byte[0]), + new SyncPutListener(), + headers); + listener.getResult(); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.DO_PUT); + } + + @Test + public void testGetStream() { + try (final FlightStream stream = client.getStream(new Ticket(new byte[0]), headers)) { + stream.next(); + } catch (Exception ignored) {} + + assertHeadersMatch(FlightMethod.DO_GET); + } + + @Test + public void testDoExchange() { + try (final FlightClient.ExchangeReaderWriter stream = client.doExchange(FlightDescriptor.command(new byte[0]), headers)) { + String ignored = stream.toString(); + } catch (Exception ignored){} + + assertHeadersMatch(FlightMethod.DO_EXCHANGE); + } + + private void assertHeadersMatch(FlightMethod method) { + for (Map.Entry entry : testHeaders.entrySet()) { + Assert.assertEquals(entry.getValue(), headersMiddleware.getCustomHeader(method, entry.getKey())); + } + } + /** + * A middleware used to test if customHeaders are being sent to the server properly. + */ + static class TestCustomHeaderMiddleware implements FlightServerMiddleware { + + public TestCustomHeaderMiddleware() { + } + + @Override + public void onBeforeSendingHeaders(CallHeaders callHeaders) { + + } + + @Override + public void onCallCompleted(CallStatus callStatus) { + + } + + @Override + public void onCallErrored(Throwable throwable) { + + } + + /** + * A factory for the middleware that keeps track of the received headers and provides a way + * to check those values for a given Flight Method. + */ + static class Factory implements FlightServerMiddleware.Factory { + private final Map receivedCallHeaders = new HashMap<>(); + + @Override + public TestCustomHeaderMiddleware onCallStarted(CallInfo callInfo, CallHeaders callHeaders, + RequestContext requestContext) { + + receivedCallHeaders.put(callInfo.method(), callHeaders); + return new TestCustomHeaderMiddleware(); + } + + public String getCustomHeader(FlightMethod method, String key) { + return receivedCallHeaders.get(method).get(key); + } + } + } +} From 38cb9ca2ad74565342a2a9ef8344c623a294c1c3 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Sat, 25 Feb 2023 00:02:29 +0000 Subject: [PATCH 06/11] Checkstyle fixes --- .../arrow/flight/client/CustomHeaderTest.java | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java index 89587beda12d..238ca46e9bb0 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -17,10 +17,28 @@ package org.apache.arrow.flight.client; -import java.util.*; - -import org.apache.arrow.flight.*; +import java.util.HashMap; +import java.util.Map; + +import org.apache.arrow.flight.Action; +import org.apache.arrow.flight.CallHeaders; +import org.apache.arrow.flight.CallInfo; +import org.apache.arrow.flight.CallStatus; +import org.apache.arrow.flight.Criteria; +import org.apache.arrow.flight.FlightCallHeaders; +import org.apache.arrow.flight.FlightClient; import org.apache.arrow.flight.FlightClient.ClientStreamListener; +import org.apache.arrow.flight.FlightDescriptor; +import org.apache.arrow.flight.FlightMethod; +import org.apache.arrow.flight.FlightServer; +import org.apache.arrow.flight.FlightServerMiddleware; +import org.apache.arrow.flight.FlightStream; +import org.apache.arrow.flight.FlightTestUtil; +import org.apache.arrow.flight.HeaderCallOption; +import org.apache.arrow.flight.NoOpFlightProducer; +import org.apache.arrow.flight.RequestContext; +import org.apache.arrow.flight.SyncPutListener; +import org.apache.arrow.flight.Ticket; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.util.AutoCloseables; @@ -32,7 +50,7 @@ /** - * Tests to ensure custom headers are passed along to the server for each command + * Tests to ensure custom headers are passed along to the server for each command. */ public class CustomHeaderTest { FlightServer server; @@ -55,11 +73,10 @@ public void setUp() throws Exception { callHeaders.insert(entry.getKey(), entry.getValue()); } headers = new HeaderCallOption(callHeaders); - server = FlightTestUtil.getStartedServer( - location -> FlightServer.builder(allocator, location, new NoOpFlightProducer()) + server = FlightTestUtil.getStartedServer(location -> + FlightServer.builder(allocator, location, new NoOpFlightProducer()) .middleware(FlightServerMiddleware.Key.of("customHeader"), headersMiddleware) - .build() - ); + .build()); client = FlightClient.builder(allocator, server.getLocation()).build(); } @@ -73,7 +90,7 @@ public void tearDown() throws Exception { public void testHandshake() { try { client.handshake(headers); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.HANDSHAKE); } @@ -82,7 +99,7 @@ public void testHandshake() { public void testGetSchema() { try { client.getSchema(FlightDescriptor.command(new byte[0]), headers); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.GET_SCHEMA); } @@ -91,7 +108,7 @@ public void testGetSchema() { public void testGetFlightInfo() { try { client.getInfo(FlightDescriptor.command(new byte[0]), headers); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.GET_FLIGHT_INFO); } @@ -100,7 +117,7 @@ public void testGetFlightInfo() { public void testListActions() { try { client.listActions(headers).iterator().next(); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.LIST_ACTIONS); } @@ -109,7 +126,7 @@ public void testListActions() { public void testListFlights() { try { client.listFlights(new Criteria(new byte[]{1}), headers).iterator().next(); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.LIST_FLIGHTS); } @@ -118,7 +135,7 @@ public void testListFlights() { public void testDoAction() { try { client.doAction(new Action("test"), headers).next(); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.DO_ACTION); } @@ -130,7 +147,7 @@ public void testStartPut() { new SyncPutListener(), headers); listener.getResult(); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.DO_PUT); } @@ -139,16 +156,19 @@ public void testStartPut() { public void testGetStream() { try (final FlightStream stream = client.getStream(new Ticket(new byte[0]), headers)) { stream.next(); - } catch (Exception ignored) {} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.DO_GET); } @Test public void testDoExchange() { - try (final FlightClient.ExchangeReaderWriter stream = client.doExchange(FlightDescriptor.command(new byte[0]), headers)) { + try (final FlightClient.ExchangeReaderWriter stream = client.doExchange( + FlightDescriptor.command(new byte[0]), + headers) + ) { String ignored = stream.toString(); - } catch (Exception ignored){} + } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.DO_EXCHANGE); } @@ -158,6 +178,7 @@ private void assertHeadersMatch(FlightMethod method) { Assert.assertEquals(entry.getValue(), headersMiddleware.getCustomHeader(method, entry.getKey())); } } + /** * A middleware used to test if customHeaders are being sent to the server properly. */ From 1c6122085d418c872d980ec5099c34eefca7b58e Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Sat, 25 Feb 2023 00:11:40 +0000 Subject: [PATCH 07/11] . --- .../org/apache/arrow/flight/client/CustomHeaderTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java index 238ca46e9bb0..080f82b58396 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -17,6 +17,7 @@ package org.apache.arrow.flight.client; +import com.google.common.collect.ImmutableMap; import java.util.HashMap; import java.util.Map; @@ -58,7 +59,7 @@ public class CustomHeaderTest { BufferAllocator allocator; TestCustomHeaderMiddleware.Factory headersMiddleware; HeaderCallOption headers; - Map testHeaders = Map.of( + Map testHeaders = ImmutableMap.of( "foo", "bar", "bar", "foo", "answer", "42" @@ -178,7 +179,7 @@ private void assertHeadersMatch(FlightMethod method) { Assert.assertEquals(entry.getValue(), headersMiddleware.getCustomHeader(method, entry.getKey())); } } - + /** * A middleware used to test if customHeaders are being sent to the server properly. */ From 27f919d8b851e638c5d4be0e1002a938dc5b1922 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Sat, 25 Feb 2023 00:18:16 +0000 Subject: [PATCH 08/11] . --- .../java/org/apache/arrow/flight/client/CustomHeaderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java index 080f82b58396..330b0fe4077c 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -17,7 +17,6 @@ package org.apache.arrow.flight.client; -import com.google.common.collect.ImmutableMap; import java.util.HashMap; import java.util.Map; @@ -48,6 +47,7 @@ import org.junit.Before; import org.junit.Test; +import com.google.common.collect.ImmutableMap; /** From 93b40e3475d6b7bcb121387e9ab684363fd545c9 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Sat, 25 Feb 2023 00:22:15 +0000 Subject: [PATCH 09/11] Better handling of null value --- .../org/apache/arrow/flight/client/CustomHeaderTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java index 330b0fe4077c..cf5054cba1e8 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -219,7 +219,11 @@ public TestCustomHeaderMiddleware onCallStarted(CallInfo callInfo, CallHeaders c } public String getCustomHeader(FlightMethod method, String key) { - return receivedCallHeaders.get(method).get(key); + CallHeaders headers = receivedCallHeaders.get(method); + if (headers == null){ + return null; + } + return headers.get(key); } } } From 0bd80dd8250c2db316757c8bdfc85ec06c9051ff Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Sat, 25 Feb 2023 00:23:50 +0000 Subject: [PATCH 10/11] . --- .../java/org/apache/arrow/flight/client/CustomHeaderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java index cf5054cba1e8..935813cdf4b1 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -220,7 +220,7 @@ public TestCustomHeaderMiddleware onCallStarted(CallInfo callInfo, CallHeaders c public String getCustomHeader(FlightMethod method, String key) { CallHeaders headers = receivedCallHeaders.get(method); - if (headers == null){ + if (headers == null) { return null; } return headers.get(key); From ab458c7e5eb317a5ef1a6c1d06b978e8105342f5 Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Sat, 25 Feb 2023 00:40:57 +0000 Subject: [PATCH 11/11] . --- .../java/org/apache/arrow/flight/client/CustomHeaderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java index 935813cdf4b1..a320d949cd7e 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/CustomHeaderTest.java @@ -168,7 +168,7 @@ public void testDoExchange() { FlightDescriptor.command(new byte[0]), headers) ) { - String ignored = stream.toString(); + stream.getReader().next(); } catch (Exception ignored) { } assertHeadersMatch(FlightMethod.DO_EXCHANGE);