Skip to content

fix: serialization null tag's value into LineProtocol #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2021
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 4.1.0 [unreleased]

### Bug Fixes
1. [#283](https://github.com/influxdata/influxdb-client-java/pull/283): Serialization `null` tag's value into LineProtocol

## 4.0.0 [2021-11-26]

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/com/influxdb/client/write/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ private void appendTags(@Nonnull final StringBuilder sb, @Nullable final PointSe
String key = tag.getKey();
String value = tag.getValue();

if (key.isEmpty() || value.isEmpty()) {
if (key.isEmpty() || value == null || value.isEmpty()) {
continue;
}

Expand Down
11 changes: 11 additions & 0 deletions client/src/test/java/com/influxdb/client/write/PointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ void tagEmptyValue() {
Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=europe level=2i");
}

@Test
void tagNullValue() {

Point point = Point.measurement("h2o")
.addTag("location", "europe")
.addTag("log", null)
.addField("level", 2);

Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=europe level=2i");
}

@Test
public void tagEscapingKeyAndValue() {

Expand Down