This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/develop by this push:
new 36637fdd3 RoyaleProject: Fixed missing binding data caused by multiple
threads accessing same HashMap (closes #182) (closes #250)
36637fdd3 is described below
commit 36637fdd3171bd2781bb70e9ec5b61d53ab5f649
Author: Josh Tynjala <[email protected]>
AuthorDate: Wed Jun 10 16:01:43 2026 -0700
RoyaleProject: Fixed missing binding data caused by multiple threads
accessing same HashMap (closes #182) (closes #250)
getBindingMap() is now a ConcurrentHashMap because multiple threads writing
to and reading from a regular HashMap can corrupt the data structure.
ConcurrentHashMap is designed to be accessed from multiple threads
simultaneously and handles locking/unlocking automatically.
During compilation, un MXMLRoyaleEmitter.emitBindingData(),
project.getBindingMap().get(cdef) was sometimes returning null (often needed
multiple compiles to reproduce). This is one sign that the HashMap wass
corrupted. Another sign of corruption is that the size() of the map may be
smaller than it should be, and not consistent between compiles (but sometimes
the size was still correct, but get() still returned null).
---
RELEASE_NOTES.md | 1 +
.../org/apache/royale/compiler/internal/projects/RoyaleProject.java | 6 ++++--
.../java/org/apache/royale/compiler/projects/IRoyaleProject.java | 3 ++-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index e9d7a3813..9b224eec2 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -84,6 +84,7 @@ Apache Royale Compiler 1.0.0
- compiler: Fixed rare race condition where certain cached values are detected
as non-null but become null before the method returns.
- compiler: Fixed parsing of namespace uri and manifest mappings to allow
multiple manifest paths per URI.
- compiler: Fixed missing require for package-level functions or variables in
some situations.
+- compiler: Fixed missing binding data caused by thread conflicts.
- debugger: Added missing isolate ID to SWF load and unload events.
- debugger: Fixed debugger targeting the current JDK version instead of the
intended minimum JDK version.
- debugger: Fixed localized messages appearing as unprocessed tokens.
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
index 1f83fa685..a9e780277 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
@@ -25,6 +25,8 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import org.apache.commons.io.FileUtils;
@@ -2732,12 +2734,12 @@ public class RoyaleProject extends ASProject implements
IRoyaleProject, ICompile
}
- private HashMap<IClassDefinition, BindingDatabase> bindingMap = new
HashMap<IClassDefinition, BindingDatabase>();
+ private ConcurrentHashMap<IClassDefinition, BindingDatabase> bindingMap =
new ConcurrentHashMap<IClassDefinition, BindingDatabase>();
/**
* Support for access to BindingData from the class definition as key.
* @return
*/
- public HashMap<IClassDefinition, BindingDatabase> getBindingMap(){
+ public ConcurrentMap<IClassDefinition, BindingDatabase> getBindingMap(){
return bindingMap;
}
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/projects/IRoyaleProject.java
b/compiler/src/main/java/org/apache/royale/compiler/projects/IRoyaleProject.java
index 0836a82b4..5fbd0c11d 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/projects/IRoyaleProject.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/projects/IRoyaleProject.java
@@ -21,6 +21,7 @@ package org.apache.royale.compiler.projects;
import java.io.File;
import java.util.*;
+import java.util.concurrent.ConcurrentMap;
import org.apache.royale.compiler.common.DependencyTypeSet;
import org.apache.royale.compiler.common.XMLName;
@@ -250,6 +251,6 @@ public interface IRoyaleProject extends IASProject,
IXMLNameResolver, IWriteOnly
* Support for access to BindingData from the class definition as key.
* @return
*/
- HashMap<IClassDefinition, BindingDatabase> getBindingMap();
+ ConcurrentMap<IClassDefinition, BindingDatabase> getBindingMap();
}