cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32934] New: - [PATCH] Same logicsheet applied twice due to race condition during startup
Date Tue, 04 Jan 2005 11:06:44 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32934>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32934

           Summary: [PATCH] Same logicsheet applied twice due to race
                    condition during startup
           Product: Cocoon 2
           Version: Current SVN 2.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P3
         Component: blocks
        AssignedTo: dev@cocoon.apache.org
        ReportedBy: Alfred.Nathaniel@swx.com


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;
-------------------------------------------------------------------------------

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message