Bug 47779

Summary: ConcurrentModificationException in XMLUtils
Product: Security - Now in JIRA Reporter: mirko
Component: SignatureAssignee: XML Security Developers Mailing List <security-dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: Java 1.4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: patch
2nd patch

Description mirko 2009-09-03 06:00:21 UTC
XMLUtils.createElementInSignatureSpace is not threadsafe.

There is a chance of getting a ConcurrentModificationException if two threads try to access this method at the same time because of an unsynchronized access to the Hashtable named 'namePrefixes'.
Comment 1 mirko 2009-09-03 06:44:25 UTC
Created attachment 24204 [details]
patch
Comment 2 mirko 2009-09-03 06:51:14 UTC
Created attachment 24205 [details]
2nd patch

fixes the same problem in another method
Comment 3 coheigea 2009-09-04 08:43:32 UTC
Good catch! Would it not be better to just declare namePrefixes as:

Collections.synchronizedMap(new HashMap());

That would remove the call to Collections.unmodifiableMap each time the method is invoked, as well as the synchronized block.

Colm.
Comment 4 coheigea 2009-10-08 04:31:22 UTC
Fix applied.

Colm.
Comment 5 coheigea 2009-10-08 04:31:22 UTC
Fix applied.

Colm.