diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-03-17 21:56:49 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-03-17 21:56:49 +0100 |
commit | 17972d59fa7e2eec6b73ba5da8234f5fa7ac2536 (patch) | |
tree | fbcc5c272480e5915b60ac0992639c083d2507d8 /src/core/lombok/javac/HandlerLibrary.java | |
parent | 362000933f46ad1d509a659e39279298440a97ec (diff) | |
download | lombok-17972d59fa7e2eec6b73ba5da8234f5fa7ac2536.tar.gz lombok-17972d59fa7e2eec6b73ba5da8234f5fa7ac2536.tar.bz2 lombok-17972d59fa7e2eec6b73ba5da8234f5fa7ac2536.zip |
[#590][refactor] Fix for deadlock in WeakHashMap. Refactored all code that used a
WeakHashMap to fake a field.
Diffstat (limited to 'src/core/lombok/javac/HandlerLibrary.java')
-rw-r--r-- | src/core/lombok/javac/HandlerLibrary.java | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java index 4306b5f2..0cab56f9 100644 --- a/src/core/lombok/javac/HandlerLibrary.java +++ b/src/core/lombok/javac/HandlerLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,16 +30,16 @@ import java.util.HashMap; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import java.util.WeakHashMap; import javax.annotation.processing.Messager; import javax.tools.Diagnostic; +import lombok.core.AnnotationValues.AnnotationValueDecodeFail; +import lombok.core.BooleanFieldAugment; import lombok.core.HandlerPriority; import lombok.core.SpiLoadUtil; import lombok.core.TypeLibrary; import lombok.core.TypeResolver; -import lombok.core.AnnotationValues.AnnotationValueDecodeFail; import lombok.javac.handlers.JavacHandlerUtil; import com.sun.tools.javac.tree.JCTree; @@ -204,13 +204,10 @@ public class HandlerLibrary { if (t != null) t.printStackTrace(); } - private static final Map<JCTree, Object> handledMap = new WeakHashMap<JCTree, Object>(); - private static final Object MARKER = new Object(); + private static final BooleanFieldAugment<JCTree> handled = BooleanFieldAugment.augment(JCTree.class, "lombok$handled"); private boolean checkAndSetHandled(JCTree node) { - synchronized (handledMap) { - return handledMap.put(node, MARKER) != MARKER; - } + return !handled.set(node); } /** |