test: add test parse ipv6 - #417
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #417 +/- ##
==========================================
+ Coverage 88.29% 88.73% +0.43%
==========================================
Files 21 21
Lines 1547 1553 +6
Branches 280 281 +1
==========================================
+ Hits 1366 1378 +12
+ Misses 83 77 -6
Partials 98 98 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds coverage for IPv6 URL parsing in InfluxDBClient initialization and introduces a validation guard in the FlightSQL client to reject URLs that don’t parse into a host (e.g., unbracketed IPv6 literals).
Changes:
- Add a JUnit test covering valid/invalid IPv6 URL forms passed to
InfluxDBClient.getInstance(...). - Add a
uri.getHost() == nullvalidation inFlightSqlClient#createLocationto fail fast on invalid URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/test/java/com/influxdb/v3/client/InfluxDBClientTest.java |
Adds IPv6 parsing test cases for InfluxDBClient.getInstance(...). |
src/main/java/com/influxdb/v3/client/internal/FlightSqlClient.java |
Adds host-null guard when converting ClientConfig.host into a gRPC Location. |
Suppressed comments (1)
src/test/java/com/influxdb/v3/client/InfluxDBClientTest.java:66
InfluxDBClientisAutoCloseableand other tests in this class use try-with-resources. Creating clients here without closing them can leak Netty/Arrow resources across the test suite. Wrap the successful cases in try-with-resources (and also use the record accessorurl()).
} else {
InfluxDBClient.getInstance(test.url, "my-token".toCharArray(), "bucket0");
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a92d35e to
ee7fc92
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (11)
src/main/java/com/influxdb/v3/client/InfluxDBClient.java:508
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
* @param host the URL of the InfluxDB server. If IPv6 is using it must be wrapped inside brackets.
src/main/java/com/influxdb/v3/client/InfluxDBClient.java:564
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
* @param connectionString connection string. If IPv6 is using it must be wrapped inside brackets.
src/main/java/com/influxdb/v3/client/InfluxDBClient.java:587
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
* <li>INFLUX_HOST - cloud/server URL. If IPv6 is using it must be wrapped inside brackets. <i>required</i></li>
src/main/java/com/influxdb/v3/client/InfluxDBClient.java:600
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
* <li>influx.host - cloud/server URL. If IPv6 is using it must be wrapped inside brackets. <i>required</i></li>
src/main/java/com/influxdb/v3/client/config/ClientConfig.java:498
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
* Sets the URL of the InfluxDB server. If IPv6 is using it must be wrapped inside brackets.
src/main/java/com/influxdb/v3/client/config/ClientConfig.java:844
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
* @param connectionString connection string in URL format. If IPv6 is using it must be wrapped inside brackets.
src/main/java/com/influxdb/v3/client/config/ClientConfig.java:394
- ClientConfig.validate() currently rethrows URISyntaxException using e.getMessage() and drops the cause, which makes the error message unstable (depends on JDK wording and may not include "Invalid URL.") and loses the underlying exception chain. Consider normalizing the message (and handling blank host) while preserving the cause for debugging.
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e.getMessage());
}
src/test/java/com/influxdb/v3/client/InfluxDBClientTest.java:68
- parseIpv6() creates InfluxDBClient instances without closing them. Since InfluxDBClient is AutoCloseable, this can leak resources (threads/connections) across tests. Also, the method declares checked exceptions that it doesn't throw directly.
@Test
void parseIpv6() throws UnknownHostException, URISyntaxException {
record Test(String url, boolean isCorrect) {
}
var tests = List.of(
src/test/java/com/influxdb/v3/client/InfluxDBClientTest.java:28
- These imports are only needed because parseIpv6() declares URISyntaxException/UnknownHostException. If the test no longer declares those checked exceptions, the imports can be removed to avoid unused-import warnings.
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.List;
src/main/java/com/influxdb/v3/client/InfluxDBClient.java:486
- Grammar: "If IPv6 is using it must be wrapped inside brackets" is ungrammatical and a bit unclear. Consider rephrasing for readability.
This issue also appears in the following locations of the same file:
- line 508
- line 564
- line 587
- line 600
* @param host the URL of the InfluxDB server. If IPv6 is using it must be wrapped inside brackets.
src/main/java/com/influxdb/v3/client/config/ClientConfig.java:56
- The documentation says "hostname or IP address", but the client code uses java.net.URI parsing and requires a full URL (scheme + host). Also, the IPv6 sentence is ungrammatical; consider rewording both for clarity.
This issue also appears in the following locations of the same file:
- line 498
- line 844
* <li>
* <code>host</code> - hostname or IP address of the InfluxDB server.
* If IPv6 is using it must be wrapped inside brackets.
* </li>
bf918af to
4fe584f
Compare
4fe584f to
ecc0474
Compare
| InfluxDBClient.getInstance(test.url(), "my-token".toCharArray(), "bucket0") | ||
| ).hasMessageContaining("Invalid URL."); | ||
| } else { | ||
| InfluxDBClient.getInstance(test.url(), "my-token".toCharArray(), "bucket0"); |
There was a problem hiding this comment.
Client never closed. In tests it is low priority issue, but existing tests create new client with try-with-resources. It should be used here too, I think.
There was a problem hiding this comment.
Fixed, please check again 🙏 .
faa7b28 to
053c94b
Compare
Closes #
Proposed Changes
java.net.URIpackage.I don't think these changes need to be in CHANGELOG.md
Checklist