From 17972d59fa7e2eec6b73ba5da8234f5fa7ac2536 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 17 Mar 2014 21:56:49 +0100 Subject: [#590][refactor] Fix for deadlock in WeakHashMap. Refactored all code that used a WeakHashMap to fake a field. --- src/core/lombok/javac/HandlerLibrary.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/core/lombok/javac/HandlerLibrary.java') 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 handledMap = new WeakHashMap(); - private static final Object MARKER = new Object(); + private static final BooleanFieldAugment handled = BooleanFieldAugment.augment(JCTree.class, "lombok$handled"); private boolean checkAndSetHandled(JCTree node) { - synchronized (handledMap) { - return handledMap.put(node, MARKER) != MARKER; - } + return !handled.set(node); } /** -- cgit