Skip to content

Commit

Permalink
8063: IMCFrame Type cache not synchronized
Browse files Browse the repository at this point in the history
Reviewed-by: hdafgard
  • Loading branch information
PyvesB authored and thegreystone committed Apr 11, 2023
1 parent 91329f1 commit 8c0d129
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/
package org.openjdk.jmc.common;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -104,14 +105,15 @@ final class Type {
* instances. The expectation is that the number of unrecognized frame types will be very
* small, usually zero, so the memory overhead of the cache stays negligible.
*/
private static final Map<String, Type> TYPE_CACHE = new LinkedHashMap<String, Type>() {
private static final long serialVersionUID = 6330800425284157773L;

@Override
protected boolean removeEldestEntry(Map.Entry<String, Type> eldest) {
return size() > TYPE_CACHE_MAX_SIZE;
}
};
private static final Map<String, Type> TYPE_CACHE = Collections
.synchronizedMap(new LinkedHashMap<String, Type>() {
private static final long serialVersionUID = 6330800425284157773L;

@Override
protected boolean removeEldestEntry(Map.Entry<String, Type> eldest) {
return size() > TYPE_CACHE_MAX_SIZE;
}
});

private final String id;
private final String name;
Expand Down

0 comments on commit 8c0d129

Please sign in to comment.