JRuby

ConcurrentModificationException In Application Startup

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.6
  • Fix Version/s: JRuby 1.2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    MacOS 10.5.6 with JDK 1.6.0 64-bit
  • Number of attachments :
    0

Description

During the startup of my app, a ConcurrentModificationException was thrown. This is a very infrequent event, and I don't have any way to consistenttly reproduce it. However, I do have the stack trace available and I am hoping that by looking at the source, someone can figure out if this is a synchronization problem.

[01/25 11:54:18] TRACE: Bun started in 0.026.
Exception in thread "NATChecker" java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
	at java.util.HashMap$EntryIterator.next(HashMap.java:834)
	at java.util.HashMap$EntryIterator.next(HashMap.java:832)
	at java.util.HashMap.putAllForCreate(HashMap.java:435)
	at java.util.HashMap.<init>(HashMap.java:225)
	at org.jruby.javasupport.JavaClass.initializeClass(JavaClass.java:491)
	at org.jruby.javasupport.JavaClass.<init>(JavaClass.java:452)
	at org.jruby.javasupport.JavaClass.createJavaClass(JavaClass.java:877)
	at org.jruby.javasupport.JavaClass.get(JavaClass.java:860)

Activity

Hide
Peter K Chan added a comment -

Sorry, I didn't finished the title of this bug before submitting it.

Please change to "ConcurrentModificationException In Application Startup"

Show
Peter K Chan added a comment - Sorry, I didn't finished the title of this bug before submitting it. Please change to "ConcurrentModificationException In Application Startup"
Hide
Charles Oliver Nutter added a comment -

Ok, this looks like a softball. The problem is that the superclass proxy is being modified at the same time a subclass wants to add all entries from it. So there's a couple easy fixes I'm looking at, the simplest of which would be just making a copy of the hash.

Show
Charles Oliver Nutter added a comment - Ok, this looks like a softball. The problem is that the superclass proxy is being modified at the same time a subclass wants to add all entries from it. So there's a couple easy fixes I'm looking at, the simplest of which would be just making a copy of the hash.
Hide
Charles Oliver Nutter added a comment -

I have a fix pending right now. The problem was that while most of the method-mining took place before classes/interfaces were made available to Ruby code, the mapping of aliases (like getProperty to get_property) did not happen until the class was actually populated with methods (a lazy process triggered in a number of ways). So there was a real chance that even if you did all your importing ahead of time, you'd end up with those collections of method names being mutated while other classes expected them to be static.

The change is fairly simple: I moved the alias mapping to the initial creation process as well. And just to be safe I also made all those collections be unmodifiable, so it would not be possible to change them after the initial creation.

Commit coming shortly.

Show
Charles Oliver Nutter added a comment - I have a fix pending right now. The problem was that while most of the method-mining took place before classes/interfaces were made available to Ruby code, the mapping of aliases (like getProperty to get_property) did not happen until the class was actually populated with methods (a lazy process triggered in a number of ways). So there was a real chance that even if you did all your importing ahead of time, you'd end up with those collections of method names being mutated while other classes expected them to be static. The change is fairly simple: I moved the alias mapping to the initial creation process as well. And just to be safe I also made all those collections be unmodifiable, so it would not be possible to change them after the initial creation. Commit coming shortly.
Hide
Charles Oliver Nutter added a comment -

Fixed in r8917.

Show
Charles Oliver Nutter added a comment - Fixed in r8917.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: