diff --git a/client/src/main/java/com/influxdb/client/write/Point.java b/client/src/main/java/com/influxdb/client/write/Point.java index cc0d38c4d2..d26a3726de 100644 --- a/client/src/main/java/com/influxdb/client/write/Point.java +++ b/client/src/main/java/com/influxdb/client/write/Point.java @@ -442,6 +442,9 @@ private void escapeKey(@Nonnull final StringBuilder sb, @Nonnull final String ke private void escapeKey(@Nonnull final StringBuilder sb, @Nonnull final String key, final boolean escapeEqual) { for (int i = 0; i < key.length(); i++) { switch (key.charAt(i)) { + case '\\': + sb.append("\\\\"); + continue; case '\n': sb.append("\\n"); continue; diff --git a/client/src/test/java/com/influxdb/client/write/PointTest.java b/client/src/test/java/com/influxdb/client/write/PointTest.java index e93827055e..b0a421e24b 100644 --- a/client/src/test/java/com/influxdb/client/write/PointTest.java +++ b/client/src/test/java/com/influxdb/client/write/PointTest.java @@ -182,6 +182,16 @@ void fieldEscape() { Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=europe level=\"string esc\\\"ape value\""); } + @Test + void tagEscape() { + Point point = Point.measurement("h2o") + .addTag("location", "\\") + .addTag("zone", "europe") + .addField("level", "dummy value"); + + Assertions.assertThat(point.toLineProtocol()).isEqualTo("h2o,location=\\\\,zone=europe level=\"dummy value\""); + } + @Test void time() {