You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/01/18 16:50:32 UTC
[groovy] branch GROOVY_3_0_X updated: Tweak lazy logic with
double-checked locking
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 0616f91 Tweak lazy logic with double-checked locking
0616f91 is described below
commit 0616f918cc7b56f986f951a1eece8b95f380de33
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jan 19 00:47:36 2020 +0800
Tweak lazy logic with double-checked locking
(cherry picked from commit 45444ed2b9e27997ef8b3927a82291bfba098325)
---
.../org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java b/src/main/java/org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java
index 1447a2d..c53029f 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/DecompiledClassNode.java
@@ -41,8 +41,8 @@ import java.util.function.Supplier;
public class DecompiledClassNode extends ClassNode {
private final ClassStub classData;
private final AsmReferenceResolver resolver;
- private boolean supersInitialized = false;
- private boolean membersInitialized = false;
+ private volatile boolean supersInitialized;
+ private volatile boolean membersInitialized;
public DecompiledClassNode(ClassStub data, AsmReferenceResolver resolver) {
super(data.className, getFullModifiers(data), null, null, MixinNode.EMPTY_ARRAY);
@@ -178,6 +178,8 @@ public class DecompiledClassNode extends ClassNode {
}
private void lazyInitSupers() {
+ if (supersInitialized) return;
+
synchronized (lazyInitLock) {
if (!supersInitialized) {
ClassSignatureParser.configureClass(this, this.classData, this.resolver);
@@ -189,6 +191,8 @@ public class DecompiledClassNode extends ClassNode {
}
private void lazyInitMembers() {
+ if (membersInitialized) return;
+
synchronized (lazyInitLock) {
if (!membersInitialized) {
if (classData.methods != null) {