aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-07-22 07:17:52 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-07-22 07:17:52 +0200
commit34055fcdff786c9b809ce1a08c1c9218968ebc7d (patch)
tree9fd3ee91725e81c4dad4b3d53eb01fbb16665d99
parent98c704c7cb4b21d0d6e11f55c52da89cb7c22502 (diff)
downloadlombok-34055fcdff786c9b809ce1a08c1c9218968ebc7d.tar.gz
lombok-34055fcdff786c9b809ce1a08c1c9218968ebc7d.tar.bz2
lombok-34055fcdff786c9b809ce1a08c1c9218968ebc7d.zip
A potential fix for issue #394; Memory leaks in eclipse introduced in lombok 0.11.2 due to a fix involving WeakHashMaps for lazy getters of type boolean.
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 7120a602..ae488612 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -773,18 +773,19 @@ public class EclipseHandlerUtil {
}
}
- private static final Map<FieldDeclaration, GetterMethod> generatedLazyGetters = new WeakHashMap<FieldDeclaration, GetterMethod>();
+ private static final Map<FieldDeclaration, Object> generatedLazyGettersWithPrimitiveBoolean = new WeakHashMap<FieldDeclaration, Object>();
+ private static final Object MARKER = new Object();
static void registerCreatedLazyGetter(FieldDeclaration field, char[] methodName, TypeReference returnType) {
- generatedLazyGetters.put(field, new GetterMethod(methodName, returnType));
+ if (!nameEquals(returnType.getTypeName(), "boolean") || returnType.dimensions() > 0) return;
+ generatedLazyGettersWithPrimitiveBoolean.put(field, MARKER);
}
private static GetterMethod findGetter(EclipseNode field) {
FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get();
- GetterMethod gm = generatedLazyGetters.get(fieldDeclaration);
- if (gm != null) return gm;
+ boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.containsKey(fieldDeclaration);
TypeReference fieldType = fieldDeclaration.type;
- boolean isBoolean = nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0;
+ boolean isBoolean = forceBool || (nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0);
EclipseNode typeNode = field.up();
for (String potentialGetterName : toAllGetterNames(field, isBoolean)) {