Data Loss bugfix / Additional Features #177
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I guess that I've found the bugfix for the data loss problem:
The data loss happens if you send field values as strings which contain a backslash following with a java specific escape sequence. (See here: Escape Sequences)
The line protocol interprets then for example
sometext\newtext
with\n
as a new line.That's why I have added line 357
stringValue = stringValue.replace("\\", "/");
in Point.java as a quick fix. If you want a more sophisticated solution it's up to you. But it seems to work.Moreover, you dont have to check the field (String) value for null in the
addField()
method (line 154 in Point.java) because you should also be able to add fields with null values. You just have to check that during theconcatenateFields()
method that you have at least one field with a value. There was also a bug in building the concatenated String if you pass null values (as a Number for example) that you had a comma at the end of the concatenated string where no comma should appear because no field has been added.I have also added an additional Feature to addFields on basis of a condition. Since InfluxDB is a schemaless DB you don't need always to add every field to the Point class and transmit it to the Server. Please check the tests in the
WriteTest.java
class