Skip to content

Commit

Permalink
fix issue: There is a thread safety issue with InfluxDBResultMapper i…
Browse files Browse the repository at this point in the history
…nfluxdata#683 (influxdata#685)

Co-authored-by: mayuefeng <[email protected]>
  • Loading branch information
mayuefeng777 and mayuefeng authored Jul 20, 2020
1 parent f590c59 commit 93c0093
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/org/influxdb/impl/InfluxDBResultMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,7 @@ void cacheMeasurementClass(final Class<?>... classVarAgrs) {
if (CLASS_FIELD_CACHE.containsKey(clazz.getName())) {
continue;
}
ConcurrentMap<String, Field> initialMap = new ConcurrentHashMap<>();
ConcurrentMap<String, Field> influxColumnAndFieldMap = CLASS_FIELD_CACHE.putIfAbsent(clazz.getName(), initialMap);
if (influxColumnAndFieldMap == null) {
influxColumnAndFieldMap = initialMap;
}
ConcurrentMap<String, Field> influxColumnAndFieldMap = new ConcurrentHashMap<>();

Class<?> c = clazz;
while (c != null) {
Expand All @@ -227,6 +223,7 @@ void cacheMeasurementClass(final Class<?>... classVarAgrs) {
}
c = c.getSuperclass();
}
CLASS_FIELD_CACHE.putIfAbsent(clazz.getName(), influxColumnAndFieldMap);
}
}

Expand Down

0 comments on commit 93c0093

Please sign in to comment.