Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
### Bug Fixes

1. [#684](https://github.com/influxdata/influxdb-client-java/issues/684): Fix checking for CSV end of table marker when parsing CSV stream to InfluxQLQueryResult, needed for example when parsing the results of a query like "SHOW SERIES".
2. [#662](https://github.com/influxdata/influxdb-client-java/issues/662): Adds to FluxDsl support for the `|> elapsed(unit)` function.
2. [#662](https://github.com/influxdata/influxdb-client-java/issues/662): Adds to FluxDsl support for the `|> elapsed(unit)` function.
3. [#623](https://github.com/influxdata/influxdb-client-java/issues/623): Enables the use of IPv6 addresses.

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,13 @@ private ParsedUrl(@Nonnull final String connectionString) {

HttpUrl url = this.httpUrl.newBuilder().build();

String urlWithoutParams = url.scheme() + "://" + url.host() + ":" + url.port() + url.encodedPath();
if (!urlWithoutParams.endsWith("/")) {
urlWithoutParams += "/";
}
//detect IPV6
String host = url.host().contains(":") ? "[" + url.host() + "]" : url.host();
String urlWithoutParams = url.scheme() + "://" + host + ":" + url.port() + url.encodedPath();

this.urlWithoutParams = urlWithoutParams;
this.urlWithoutParams = urlWithoutParams.endsWith("/")
? urlWithoutParams
: urlWithoutParams + "/";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
*/
package com.influxdb.client;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.influxdb.client.domain.WritePrecision;

import com.influxdb.exceptions.InfluxException;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import org.assertj.core.api.Assertions;
Expand Down Expand Up @@ -156,4 +159,71 @@ public void customClientTypeFromProperties() {

Assertions.assertThat(options.getClientType()).isEqualTo("properties-service");
}

@Test
public void ipv6Loopback(){
String[] loopbacks = {"[::1]", "[0000:0000:0000:0000:0000:0000:0000:0001]"};

for (String loopback : loopbacks) {
InfluxDBClientOptions options = InfluxDBClientOptions.builder()
.url(String.format("http://%s:9999/api/v2/", loopback))
.authenticateToken("xyz".toCharArray())
.org("my-org")
.build();

Assertions.assertThat(options.getUrl()).isEqualTo("http://[::1]:9999/api/v2/");
Assertions.assertThat(options.getAuthScheme()).isEqualTo(InfluxDBClientOptions.AuthScheme.TOKEN);
Assertions.assertThat(options.getOkHttpClient()).isNotNull();
Assertions.assertThat(options.getPrecision()).isEqualTo(WritePrecision.NS);
Assertions.assertThat(options.getOrg()).isEqualTo("my-org");
}
}

@Test
public void ipv6General(){
Map<String, String> ipv6Expected = Map.of(
"[2001:db80:0001:1000:1100:0011:1110:0111]", "[2001:db80:1:1000:1100:11:1110:111]",
"[2001:db8:1000:0000:0000:0000:0000:0001]", "[2001:db8:1000::1]",
"[2001:db8f:0ff0:00ee:0ddd:000c:bbbb:aaaa]", "[2001:db8f:ff0:ee:ddd:c:bbbb:aaaa]",
"[2001:0db8:0000:0000:0000:9876:0000:001f]", "[2001:db8::9876:0:1f]",
"[0000:0000:0000:0000:0000:0000:0000:0000]", "[::]",
"[2001:0db8:fedc:edcb:dcba:cba9:ba98:a987]", "[2001:db8:fedc:edcb:dcba:cba9:ba98:a987]"//,
//"[::1]", ""
);

for(String key : ipv6Expected.keySet()){
InfluxDBClientOptions options = InfluxDBClientOptions.builder()
.url(String.format("http://%s:9999/api/v2/query?orgID=my-org", key))
.authenticateToken("xyz".toCharArray())
.build();

System.out.println(key + ": " + options.getUrl());

Assertions.assertThat(options.getUrl())
.isEqualTo(String.format("http://%s:9999/api/v2/query/", ipv6Expected.get(key)));
Assertions.assertThat(options.getToken())
.isEqualTo("xyz".toCharArray());
}
}

@Test
public void ipv6Invalid(){
List<String> invalidIpv6 = Arrays.asList(
"[:1]",
"[:::1]",
"[2001:db8:0000:1]",
"[2001:db8:00000::1]",
"[2001:db8:0000:::1]",
"[:0000::1]",
"[:::0000::1]");
for(String ipv6 : invalidIpv6){
Assertions.assertThatThrownBy(() -> { InfluxDBClientOptions options2 = InfluxDBClientOptions.builder()
.url(String.format("http://%s:9999/api/v2/query?orgID=my-org", ipv6))
.authenticateToken("xyz".toCharArray())
.build();}).isInstanceOf(InfluxException.class)
.hasMessage(String.format("Unable to parse connection string http://%s:9999/api/v2/query?orgID=my-org", ipv6));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package com.influxdb.client;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.List;
Expand All @@ -31,6 +33,9 @@
import java.util.logging.Logger;
import javax.annotation.Nonnull;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpHandler;
import com.influxdb.LogLevel;
import com.influxdb.client.domain.Authorization;
import com.influxdb.client.domain.Run;
Expand Down