Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.1.8
-
None
-
None
-
Operating System: All
Platform: All
-
32934
Description
In a.o.c.components.language.markup.AbstractMarkupLanguage.addLogicsheetToList
there is a race condition between fetching and storing a logicsheet in the
cache. Two threads may find the cache empty and each create a new Logicsheet
for the same input source. The race condition itself is benign. It only
wastes a few CPU cycles during startup.
However, addLogicsheetToList can be called several times for the same
logicsheetLocation, leading to duplicate entries in logicSheetList. These
duplicates are supposed to be removed in addLogicsheetToGenerator:
if(newLogicSheetList.indexOf(logicsheet) == -1)
Since Logicsheet.equals() is not implemented, currently this check only removes
identical Logicsheet objects. The race condition, however, can lead to non-
identical duplicates for the same logicsheet. Depending on the logicsheet,
this can lead to spurious XSP compilation errors (duplicate definitions of Java
identifiers) or, worse, unexpected runtime behaviour.
PATCH
=====
Implement a.o.c.components.language.markup.Logicsheet.equals and
Logicsheet.hashCode, based on systemId:
-------------------------------------------------------------------------------
+ /**
+ * Return true if other logicsheet has the same system id.
+ */
+ public boolean equals(Object other)
+ {
+ if (other == this)
+ return true;
+ if (other == null)
+ return false;
+ if (!(other instanceof Logicsheet))
+ return false;
+ Logicsheet that = (Logicsheet)other;
+ return this.systemId.equals(that.systemId);
+ }
+
+ /**
+ * Return hash code value for logicsheet.
+ */
+ public int hashCode()
+ {
+ return this.systemId.hashCode();
+ }
+
public String getSystemId()
{
return this.systemId;
-------------------------------------------------------------------------------
there is a race condition between fetching and storing a logicsheet in the
cache. Two threads may find the cache empty and each create a new Logicsheet
for the same input source. The race condition itself is benign. It only
wastes a few CPU cycles during startup.
However, addLogicsheetToList can be called several times for the same
logicsheetLocation, leading to duplicate entries in logicSheetList. These
duplicates are supposed to be removed in addLogicsheetToGenerator:
if(newLogicSheetList.indexOf(logicsheet) == -1)
Since Logicsheet.equals() is not implemented, currently this check only removes
identical Logicsheet objects. The race condition, however, can lead to non-
identical duplicates for the same logicsheet. Depending on the logicsheet,
this can lead to spurious XSP compilation errors (duplicate definitions of Java
identifiers) or, worse, unexpected runtime behaviour.
PATCH
=====
Implement a.o.c.components.language.markup.Logicsheet.equals and
Logicsheet.hashCode, based on systemId:
-------------------------------------------------------------------------------
+ /**
+ * Return true if other logicsheet has the same system id.
+ */
+ public boolean equals(Object other)
+ {
+ if (other == this)
+ return true;
+ if (other == null)
+ return false;
+ if (!(other instanceof Logicsheet))
+ return false;
+ Logicsheet that = (Logicsheet)other;
+ return this.systemId.equals(that.systemId);
+ }
+
+ /**
+ * Return hash code value for logicsheet.
+ */
+ public int hashCode()
+ {
+ return this.systemId.hashCode();
+ }
+
public String getSystemId()
{
return this.systemId;
-------------------------------------------------------------------------------