Skip to content

Commit

Permalink
Some fixes to the usage of the usageMapRef
Browse files Browse the repository at this point in the history
  • Loading branch information
akang31 committed Jan 19, 2024
1 parent 8f8bad6 commit 762634b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ private void flushUsageData() {

/** Merge the results of given accessMonitorUtil into this one. */
public void merge(AccessMonitorUtil accessMonitorUtil) {
Map<String, PropertyUsageData> myMap = propertyUsageMapRef.get();
for (Map.Entry<String, PropertyUsageData> entry : accessMonitorUtil.propertyUsageMapRef.get().entrySet()) {
propertyUsageMapRef.get().putIfAbsent(entry.getKey(), entry.getValue());
myMap.putIfAbsent(entry.getKey(), entry.getValue());
}
for (Map.Entry<String, Integer> entry : accessMonitorUtil.stackTrace.entrySet()) {
stackTrace.merge(entry.getKey(), entry.getValue(), Integer::sum);
Expand Down Expand Up @@ -140,7 +141,7 @@ private List<PropertyUsageEvent> createEventList(PropertyUsageEvent event) {

private Map<String, PropertyUsageData> getAndClearUsageMap() {
Map<String, PropertyUsageData> map = propertyUsageMapRef.getAndSet(new ConcurrentHashMap<>());
return Collections.unmodifiableMap(new HashMap<>(map));
return Collections.unmodifiableMap(map);
}

public Map<String, PropertyUsageData> getUsageMapImmutable() {
Expand Down

0 comments on commit 762634b

Please sign in to comment.