There's nothing in BatchPoints.Builder javadoc that would warn against calling build() multiple times:
|
/** |
|
* The Builder to create a new BatchPoints instance. |
|
*/ |
|
public static final class Builder { |
|
/** |
|
* Create a new BatchPoints instance. |
|
* |
|
* @return the created BatchPoints. |
|
*/ |
|
public BatchPoints build() { |
and nothing in build() method itself that would cause ie exception:
|
public BatchPoints build() { |
|
BatchPoints batchPoints = new BatchPoints(); |
|
batchPoints.setDatabase(this.database); |
|
for (Point point : this.points) { |
|
point.getTags().putAll(this.tags); |
|
} |
|
batchPoints.setPoints(this.points); |
|
batchPoints.setRetentionPolicy(this.retentionPolicy); |
|
batchPoints.setTags(this.tags); |
|
if (null == this.consistency) { |
|
this.consistency = ConsistencyLevel.ONE; |
|
} |
|
batchPoints.setConsistency(this.consistency); |
|
if (null == this.precision) { |
|
this.precision = TimeUnit.NANOSECONDS; |
|
} |
|
batchPoints.setPrecision(this.precision); |
|
return batchPoints; |
|
} |
but creating multiple BatchPoints instances from BatchPoints.Builder is not actually safe since BatchPoints.Builder does not make defensive copy of this.points:
|
batchPoints.setPoints(this.points); |
so ie this code will fail:
BatchPoints bp1 = builder.build();
int size = bp1.getPoints().size();
bp1.point(point);
BatchPoints bp2 = builder.build();
assertEquals(size, bp2.getPoints().size());
since bp1.point(point) modified collection builder refers to.
There's nothing in
BatchPoints.Builderjavadoc that would warn against callingbuild()multiple times:influxdb-java/src/main/java/org/influxdb/dto/BatchPoints.java
Lines 54 to 57 in b1d1d8a
influxdb-java/src/main/java/org/influxdb/dto/BatchPoints.java
Lines 151 to 156 in b1d1d8a
and nothing in
build()method itself that would cause ie exception:influxdb-java/src/main/java/org/influxdb/dto/BatchPoints.java
Lines 156 to 174 in b1d1d8a
but creating multiple
BatchPointsinstances fromBatchPoints.Builderis not actually safe sinceBatchPoints.Builderdoes not make defensive copy ofthis.points:influxdb-java/src/main/java/org/influxdb/dto/BatchPoints.java
Line 162 in b1d1d8a
so ie this code will fail:
since
bp1.point(point)modified collectionbuilderrefers to.