Skip to content

Commit 17fb8fa

Browse files
authored
fix: serialization null tag's value into LineProtocol (#283)
1 parent f2ef610 commit 17fb8fa

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 4.1.0 [unreleased]
22

3+
### Bug Fixes
4+
1. [#283](https://github.com/influxdata/influxdb-client-java/pull/283): Serialization `null` tag's value into LineProtocol
5+
36
## 4.0.0 [2021-11-26]
47

58
### Breaking Changes

client/src/main/java/com/influxdb/client/write/Point.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private void appendTags(@Nonnull final StringBuilder sb, @Nullable final PointSe
347347
String key = tag.getKey();
348348
String value = tag.getValue();
349349

350-
if (key.isEmpty() || value.isEmpty()) {
350+
if (key.isEmpty() || value == null || value.isEmpty()) {
351351
continue;
352352
}
353353

client/src/test/java/com/influxdb/client/write/PointTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ void tagEmptyValue() {
103103
Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=europe level=2i");
104104
}
105105

106+
@Test
107+
void tagNullValue() {
108+
109+
Point point = Point.measurement("h2o")
110+
.addTag("location", "europe")
111+
.addTag("log", null)
112+
.addField("level", 2);
113+
114+
Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=europe level=2i");
115+
}
116+
106117
@Test
107118
public void tagEscapingKeyAndValue() {
108119

0 commit comments

Comments
 (0)