Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Parser returned from LaunchingPlugin.getParser() not threadsafe(What can we lock on to ensure no 2 threads modify launch configuration at the same time?)
Parser returned from LaunchingPlugin.getParser() not threadsafe [message #639555] Tue, 16 November 2010 21:36 Go to next message
Mike Youngstrom is currently offline Mike YoungstromFriend
Messages: 6
Registered: July 2009
Junior Member
I've noticed several places in eclipse's code base that invoke LaunchingPlugin.getParser() to acquire a DocumentBuilder instance to parse some xml. This is fine except that when used in this way LaunchingPlugin is functioning as a singleton and the DocumentBuilder implementation returned from LaunchingPlugin is not threadsafe.

This causes exceptions similar to:

org.xml.sax.SAXException: FWK005 parse may not be called while parsing.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(D OMParser.java:263)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl. parse(DocumentBuilderImpl.java:284)

Should LaunchPlugin be modified to return a new instance of DocumentBuilder for each thread? I cannot seem to find any unifying place where modification of launch configurations can be synchronized. In a quick search of some code I found JavaRuntime.newRuntimeClasspathEntry() and Tomcat60Configuration.load() both invoking LaunchPlugin.getParser() directly so it appears plugin developers are assuming the DocumentBuilder returned from LaunchPlugin.getParser() is threadsafe.

Thoughs? Should I file an issue?

Mike
Re: Parser returned from LaunchingPlugin.getParser() not threadsafe [message #639609 is a reply to message #639555] Wed, 17 November 2010 07:53 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
On 11/16/10 1:36 PM, Mike Youngstrom wrote:
> I've noticed several places in eclipse's code base that invoke
> LaunchingPlugin.getParser() to acquire a DocumentBuilder instance to
> parse some xml. This is fine except that when used in this way
> LaunchingPlugin is functioning as a singleton and the DocumentBuilder
> implementation returned from LaunchingPlugin is not threadsafe.
>
> [...]
> In a quick search of some code I found
> JavaRuntime.newRuntimeClasspathEntry() and Tomcat60Configuration.load()
> both invoking LaunchPlugin.getParser() directly so it appears plugin
> developers are assuming the DocumentBuilder returned from
> LaunchPlugin.getParser() is threadsafe.
>
> Thoughs? Should I file an issue?


How is Tomcat60Configuration accessing LaunchPlugin.getParser()? (I
don't have the WTP code handy so I can't look for myself...)

LaunchPlugin is in org.eclipse.jdt.internal - it shouldn't be visible to
other plugins, at least according to the MANIFEST.MF. If other plugins
are accessing that method, that sounds like a bug right there.
Re: Parser returned from LaunchingPlugin.getParser() not threadsafe [message #639804 is a reply to message #639609] Wed, 17 November 2010 21:07 Go to previous messageGo to next message
Mike Youngstrom is currently offline Mike YoungstromFriend
Messages: 6
Registered: July 2009
Junior Member
Ah, my mistake. The tomcat plugin is actually using it's own DocumentBuilder singleton in its XMLUtil.class. So the Tomcat plugin has the same problem but with its own DocumentBuilder instance. I'll bring that up with the tomcat group.

For the JDT though. I'm seeing a problem where if I update 2 launch configurations at the same time I'm getting a "org.xml.sax.SAXException: FWK005 parse may not be called while parsing." error. Is there something I should be locking on when making and launch configuration change?

Here is the full stacktrace I get when modifying 2 Tomcat launch configurations at the same time. The org.lds.stack.ide.server.LdsTechServer is a custom Server Adapter that extends the Tomcat 6 server adapter.

org.eclipse.core.runtime.CoreException: Unable to restore classpath entry.
at org.eclipse.jdt.launching.JavaRuntime.abort(JavaRuntime.java :1354)
at org.eclipse.jdt.launching.JavaRuntime.abort(JavaRuntime.java :1340)
at org.eclipse.jdt.launching.JavaRuntime.newRuntimeClasspathEnt ry(JavaRuntime.java:725)
at org.eclipse.jdt.launching.StandardClasspathProvider.recoverR untimePath(StandardClasspathProvider.java:100)
at org.eclipse.jdt.launching.StandardClasspathProvider.computeU nresolvedClasspath(StandardClasspathProvider.java:65)
at org.eclipse.jdt.launching.JavaRuntime.computeUnresolvedRunti meClasspath(JavaRuntime.java:1200)
at org.eclipse.jst.server.tomcat.core.internal.TomcatServerBeha viour.setupLaunchConfiguration(TomcatServerBehaviour.java:89 3)
at org.eclipse.wst.server.core.internal.Server.setupLaunchConfi guration(Server.java:1537)
at org.eclipse.wst.server.core.internal.Server.getLaunchConfigu ration(Server.java:1580)
at org.lds.stack.ide.server.LdsTechServer.getLaunchConfiguratio n(LdsTechServer.java:68)
at org.lds.stack.ide.server.configurers.VmArgsConfigurer.config ureServers(VmArgsConfigurer.java:33)
at org.lds.stack.ide.server.configurers.VmArgsConfigurer.config ure(VmArgsConfigurer.java:72)
at org.lds.stack.ide.server.configurers.ConfigureRunner.invokeC onfigurer(ConfigureRunner.java:55)
at org.lds.stack.ide.server.configurers.ConfigureRunner.run(Con figureRunner.java:31)
at org.lds.stack.ide.server.ServerPluginActivator$2.runInWorksp ace(ServerPluginActivator.java:80)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run (InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.xml.sax.SAXException: FWK005 parse may not be called while parsing.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(D OMParser.java:263)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl. parse(DocumentBuilderImpl.java:284)
at org.eclipse.jdt.launching.JavaRuntime.newRuntimeClasspathEnt ry(JavaRuntime.java:702)
... 14 more
Re: Parser returned from LaunchingPlugin.getParser() not threadsafe [message #640661 is a reply to message #639804] Mon, 22 November 2010 17:54 Go to previous message
Mike Youngstrom is currently offline Mike YoungstromFriend
Messages: 6
Registered: July 2009
Junior Member
Bump.

I get the exception above whenever invoking org.eclipse.jdt.launching.JavaRuntime.newRuntimeClasspathEnt ry() from 2 threads at the same time. What should I do to avoid this? Should I file a bug?
Previous Topic:JUnit 4 / JUNIT_HOME Problem
Next Topic:XML Parser
Goto Forum:
  


Current Time: Thu Mar 28 14:52:59 GMT 2024

Powered by FUDForum. Page generated in 0.01901 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top