Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static final class LineError {
* @param originalLine original line protocol row; may be null if not provided by server
*/
public LineError(@Nullable final Integer lineNumber,
@Nonnull final String errorMessage,
@Nullable final String errorMessage,
@Nullable final String originalLine) {
this.lineNumber = lineNumber;
this.errorMessage = errorMessage;
Expand All @@ -94,7 +94,7 @@ public Integer lineNumber() {
/**
* @return line-level error message
*/
@Nonnull
@Nullable
public String errorMessage() {
return errorMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private <T> void writeData(@Nonnull final List<T> data, @Nonnull final WriteOpti
headers.putAll(options.headersSafe());

try {
restClient.request(path, HttpMethod.POST, body, queryParams, headers);
restClient.request(path, HttpMethod.POST, body, queryParams, headers, acceptPartial, useV2Api);
} catch (InfluxDBApiHttpException e) {
if (e.statusCode() == HttpResponseStatus.METHOD_NOT_ALLOWED.code()) {
if (useV2Api && "api/v2/write".equals(path)) {
Expand Down
360 changes: 171 additions & 189 deletions src/main/java/com/influxdb/v3/client/internal/RestClient.java

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions src/main/java/com/influxdb/v3/client/internal/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.influxdb.v3.client.internal;

public final class Utils {

private Utils() {
}

/**
* Determines if the provided string can be parsed into a valid integer.
*
* @param str the string to check; may be null or empty
* @return {@code true} if the string can be parsed into an integer; {@code false} otherwise
*/
public static boolean isInteger(final String str) {
if (str == null || str.isEmpty()) {
return false;
}
try {
Integer.parseInt(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}
17 changes: 5 additions & 12 deletions src/test/java/com/influxdb/v3/client/integration/E2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,11 @@ public void testWriteErrorWithoutAcceptPartial() throws Exception {
.acceptPartial(false)
.build();
Throwable thrown = Assertions.catchThrowable(() -> client.writeRecord(points, options));
Assertions.assertThat(thrown).isInstanceOf(InfluxDBPartialWriteException.class);
Assertions.assertThat(thrown.getMessage())
.contains("line protocol parsing error");

InfluxDBPartialWriteException partialError = (InfluxDBPartialWriteException) thrown;
Assertions.assertThat(partialError.lineErrors()).hasSize(1);
Assertions.assertThat(partialError.lineErrors().get(0).lineNumber()).isEqualTo(2);
Assertions.assertThat(partialError.lineErrors().get(0).errorMessage())
.isEqualTo("invalid column type for column 'temp', expected iox::column_type::field::float, "
+ "got iox::column_type::field::string");
Assertions.assertThat(partialError.lineErrors().get(0).originalLine())
.isEqualTo("home,room=Sunroom te");
Assertions.assertThat(thrown).isInstanceOf(InfluxDBApiHttpException.class);
Assertions.assertThat(thrown.getMessage()).isEqualTo("HTTP status code: 400; Message: line "
+ "protocol parsing error:\n"
+ "\tline 2: invalid column type for column 'temp', expected iox::column_type::field::float, "
+ "got iox::column_type::field::string (home,room=Sunroom te)");
}
}

Expand Down
Loading
Loading