Fix the cache unclear bug. (#4739)
* Fix the cache unclear bug. * Update LimitedSizeBufferedData.java Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
This commit is contained in:
parent
c33f583806
commit
a2eddd699e
|
|
@ -74,8 +74,12 @@ public class LimitedSizeBufferedData<STORAGE_DATA extends ComparableStorageData
|
|||
|
||||
@Override
|
||||
public List<STORAGE_DATA> read() {
|
||||
List<STORAGE_DATA> collection = new ArrayList<>();
|
||||
data.values().forEach(e -> e.forEach(collection::add));
|
||||
return collection;
|
||||
try {
|
||||
List<STORAGE_DATA> collection = new ArrayList<>();
|
||||
data.values().forEach(collection::addAll);
|
||||
return collection;
|
||||
} finally {
|
||||
data.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ public class MergableBufferedData<METRICS extends Metrics> implements BufferedDa
|
|||
|
||||
@Override
|
||||
public List<METRICS> read() {
|
||||
return buffer.values().stream().collect(Collectors.toList());
|
||||
try {
|
||||
return buffer.values().stream().collect(Collectors.toList());
|
||||
} finally {
|
||||
buffer.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue