Skip to content

Commit 23908be

Browse files
authored
chore: upgrade Arrow Flight client dependencies (#352)
* chore: upgrade and align Arrow Flight client dependencies * test: add query timeout test
1 parent 777dcdb commit 23908be

4 files changed

Lines changed: 118 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 1.8.0 [unreleased]
22

3+
### Features
4+
5+
1. [#352](https://github.com/InfluxCommunity/influxdb3-java/pull/352): Update Apache Flight client dependencies.
6+
37
### CI
48

59
1. [#313](https://github.com/InfluxCommunity/influxdb3-java/pull/313): Clarify JDK 25+ requirements.

pom.xml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,51 @@
9090

9191
<junit-jupiter.version>5.14.3</junit-jupiter.version>
9292
<junit-platform.version>1.14.3</junit-platform.version>
93-
<netty-handler.version>4.2.10.Final</netty-handler.version>
93+
<arrow.version>18.3.0</arrow.version>
94+
<!-- grpc-bom 1.79.0 is very likely incompatible with Arrow 18.3.0 -->
95+
<grpc-bom.version>1.78.0</grpc-bom.version>
96+
<!-- keep aligned with gRPC/Arrow -->
97+
<netty-bom.version>4.1.127.Final</netty-bom.version>
9498

9599
<plugin.surefire.version>3.5.4</plugin.surefire.version>
96100
<plugin.jacoco.version>0.8.14</plugin.jacoco.version>
97101
<plugin.checkstyle.version>3.6.0</plugin.checkstyle.version>
98102
<plugin.javadoc.version>3.12.0</plugin.javadoc.version>
99103
</properties>
100104

105+
<dependencyManagement>
106+
<dependencies>
107+
<dependency>
108+
<groupId>org.apache.arrow</groupId>
109+
<artifactId>arrow-bom</artifactId>
110+
<version>${arrow.version}</version>
111+
<type>pom</type>
112+
<scope>import</scope>
113+
</dependency>
114+
115+
<dependency>
116+
<groupId>io.grpc</groupId>
117+
<artifactId>grpc-bom</artifactId>
118+
<version>${grpc-bom.version}</version>
119+
<type>pom</type>
120+
<scope>import</scope>
121+
</dependency>
122+
123+
<dependency>
124+
<groupId>io.netty</groupId>
125+
<artifactId>netty-bom</artifactId>
126+
<version>${netty-bom.version}</version>
127+
<type>pom</type>
128+
<scope>import</scope>
129+
</dependency>
130+
</dependencies>
131+
</dependencyManagement>
132+
101133
<dependencies>
102134

103135
<dependency>
104136
<groupId>org.apache.arrow</groupId>
105137
<artifactId>flight-core</artifactId>
106-
<version>18.3.0</version>
107138
<exclusions>
108139
<exclusion>
109140
<groupId>org.slf4j</groupId>
@@ -171,19 +202,16 @@
171202
<dependency>
172203
<groupId>io.netty</groupId>
173204
<artifactId>netty-handler</artifactId>
174-
<version>${netty-handler.version}</version>
175205
</dependency>
176206

177207
<dependency>
178208
<groupId>io.netty</groupId>
179209
<artifactId>netty-buffer</artifactId>
180-
<version>${netty-handler.version}</version>
181210
</dependency>
182211

183212
<dependency>
184213
<groupId>io.netty</groupId>
185214
<artifactId>netty-codec</artifactId>
186-
<version>${netty-handler.version}</version>
187215
<exclusions>
188216
<exclusion>
189217
<groupId>io.netty</groupId>
@@ -195,7 +223,6 @@
195223
<dependency>
196224
<groupId>io.netty</groupId>
197225
<artifactId>netty-codec-http2</artifactId>
198-
<version>${netty-handler.version}</version>
199226
<exclusions>
200227
<exclusion>
201228
<groupId>io.netty</groupId>
@@ -211,13 +238,11 @@
211238
<dependency>
212239
<groupId>io.netty</groupId>
213240
<artifactId>netty-transport-native-unix-common</artifactId>
214-
<version>${netty-handler.version}</version>
215241
</dependency>
216242

217243
<dependency>
218244
<groupId>io.netty</groupId>
219245
<artifactId>netty-tcnative-boringssl-static</artifactId>
220-
<version>2.0.75.Final</version>
221246
</dependency>
222247

223248
<dependency>

src/test/java/com/influxdb/v3/client/integration/E2ETest.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class E2ETest {
5959
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_TOKEN", matches = ".*")
6060
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_DATABASE", matches = ".*")
6161
@Test
62-
void testQueryWithProxy() {
62+
void testQueryWithProxy() throws Exception {
6363
String proxyUrl = "http://localhost:10000";
6464

6565
try {
@@ -82,17 +82,18 @@ void testQueryWithProxy() {
8282
.proxyUrl(proxyUrl)
8383
.build();
8484

85-
InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig);
86-
influxDBClient.writePoint(
87-
Point.measurement("test1")
88-
.setField("field", "field1")
89-
);
85+
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig)) {
86+
influxDBClient.writePoint(
87+
Point.measurement("test1")
88+
.setField("field", "field1")
89+
);
9090

91-
try (Stream<PointValues> stream = influxDBClient.queryPoints("SELECT * FROM test1")) {
92-
stream.findFirst()
93-
.ifPresent(pointValues -> {
94-
Assertions.assertThat(pointValues.getField("field")).isEqualTo("field1");
95-
});
91+
try (Stream<PointValues> stream = influxDBClient.queryPoints("SELECT * FROM test1")) {
92+
stream.findFirst()
93+
.ifPresent(pointValues -> {
94+
Assertions.assertThat(pointValues.getField("field")).isEqualTo("field1");
95+
});
96+
}
9697
}
9798
}
9899

@@ -110,15 +111,16 @@ void correctSslCertificates() throws Exception {
110111
.database(System.getenv("TESTING_INFLUXDB_DATABASE"))
111112
.sslRootsFilePath(influxDBcertificateFile)
112113
.build();
113-
InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig);
114-
assertGetDataSuccess(influxDBClient);
114+
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig)) {
115+
assertGetDataSuccess(influxDBClient);
116+
}
115117
}
116118

117119
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_URL", matches = ".*")
118120
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_TOKEN", matches = ".*")
119121
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_DATABASE", matches = ".*")
120122
@Test
121-
void disableServerCertificateValidation() {
123+
void disableServerCertificateValidation() throws Exception {
122124
String wrongCertificateFile = "src/test/java/com/influxdb/v3/client/testdata/docker.com.pem";
123125

124126
ClientConfig clientConfig = new ClientConfig.Builder()
@@ -130,8 +132,9 @@ void disableServerCertificateValidation() {
130132
.build();
131133

132134
// Test succeeded with wrong certificate file because disableServerCertificateValidation is true
133-
InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig);
134-
assertGetDataSuccess(influxDBClient);
135+
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig)) {
136+
assertGetDataSuccess(influxDBClient);
137+
}
135138
}
136139

137140
@EnabledIfEnvironmentVariable(named = "TESTING_INFLUXDB_URL", matches = ".*")

src/test/java/com/influxdb/v3/client/query/QueryOptionsTest.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.time.Duration;
2828
import java.util.HashMap;
2929
import java.util.Map;
30+
import java.util.concurrent.CountDownLatch;
3031
import java.util.concurrent.Executor;
3132
import java.util.concurrent.Executors;
3233
import java.util.concurrent.TimeUnit;
@@ -39,15 +40,20 @@
3940
import org.apache.arrow.flight.CallOption;
4041
import org.apache.arrow.flight.CallOptions;
4142
import org.apache.arrow.flight.CallStatus;
43+
import org.apache.arrow.flight.FlightProducer.CallContext;
44+
import org.apache.arrow.flight.FlightProducer.ServerStreamListener;
4245
import org.apache.arrow.flight.FlightRuntimeException;
4346
import org.apache.arrow.flight.FlightServer;
47+
import org.apache.arrow.flight.NoOpFlightProducer;
48+
import org.apache.arrow.flight.Ticket;
4449
import org.apache.arrow.flight.impl.FlightServiceGrpc;
4550
import org.apache.arrow.memory.BufferAllocator;
4651
import org.apache.arrow.memory.RootAllocator;
4752
import org.apache.arrow.vector.VectorSchemaRoot;
4853
import org.assertj.core.api.Assertions;
4954
import org.junit.jupiter.api.BeforeEach;
5055
import org.junit.jupiter.api.Test;
56+
import org.junit.jupiter.api.Timeout;
5157

5258
import com.influxdb.v3.client.InfluxDBClient;
5359
import com.influxdb.v3.client.PointValues;
@@ -186,6 +192,62 @@ void setInboundMessageSizeLarge() throws Exception {
186192
}
187193
}
188194

195+
@Test
196+
@Timeout(5)
197+
void queryTimeout() throws Exception {
198+
int freePort = findFreePort();
199+
URI uri = URI.create("http://127.0.0.1:" + freePort);
200+
CountDownLatch serverStreamFinished = new CountDownLatch(1);
201+
try (VectorSchemaRoot vectorSchemaRoot = TestUtils.generateVectorSchemaRoot(1, 1);
202+
BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
203+
FlightServer flightServer = TestUtils.simpleFlightServer(uri, allocator, new NoOpFlightProducer() {
204+
@Override
205+
public void getStream(final CallContext context,
206+
final Ticket ticket,
207+
final ServerStreamListener listener) {
208+
listener.start(vectorSchemaRoot);
209+
try {
210+
Thread.sleep(1000);
211+
if (!context.isCancelled() && !listener.isCancelled()) {
212+
listener.completed();
213+
}
214+
} catch (InterruptedException e) {
215+
Thread.currentThread().interrupt();
216+
} finally {
217+
serverStreamFinished.countDown();
218+
}
219+
}
220+
})
221+
) {
222+
flightServer.start();
223+
224+
String host = String.format("http://%s:%d", uri.getHost(), uri.getPort());
225+
ClientConfig clientConfig = new ClientConfig.Builder()
226+
.host(host)
227+
.database("test")
228+
.queryTimeout(Duration.ofMillis(200))
229+
.build();
230+
231+
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig)) {
232+
Throwable thrown = Assertions.catchThrowable(() -> {
233+
try (Stream<PointValues> stream = influxDBClient.queryPoints(
234+
"Select * from \"nothing\""
235+
)) {
236+
stream.count();
237+
}
238+
});
239+
240+
Assertions.assertThat(thrown).isInstanceOf(FlightRuntimeException.class);
241+
FlightRuntimeException fre = (FlightRuntimeException) thrown;
242+
Assertions.assertThat(fre.status().code()).isEqualTo(CallStatus.TIMED_OUT.code());
243+
}
244+
245+
Assertions.assertThat(serverStreamFinished.await(2, TimeUnit.SECONDS)).isTrue();
246+
flightServer.shutdown();
247+
flightServer.awaitTermination(2, TimeUnit.SECONDS);
248+
}
249+
}
250+
189251
@Test
190252
void defaultGrpcCallOptions() {
191253
GrpcCallOptions grpcCallOptions = new QueryOptions("test").grpcCallOptions();

0 commit comments

Comments
 (0)