0

I am using Drools 5.6.0.Final of knowledge-api drools code. It's using this CompositeClassLoader http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.drools/knowledge-api/5.6.0.Final/org/drools/util/CompositeClassLoader.java#CompositeClassLoader

I believe this then gets invoked by http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.drools/knowledge-api/5.6.0.Final/org/drools/util/ClassLoaderUtil.java?av=f

The CompositeClassLoader.java has a bug in it for multi-threading environment on the CachingLoader (on the HashMap put method).

I am trying to avoid patching the drools code itself and trying to wrap it with our own custom loader.

Can anyone please show me how?

I've read through these http://www.javablogging.com/java-classloader-2-write-your-own-classloader/ however I am still unsure how the code I am about to create will be invoked when the application starts up and override the drools class loader.

Any help is really appreciated. Thanks & regards voki

Tin Ng
  • 937
  • 2
  • 11
  • 25
  • Report the bug, submit the patch and apply the patch to your own code. If the patch is not accepted by the project (if actually a bug this is unlikely) then you can start looking at more exotic solutions. ClassLoaders are tricky business and you need to know exactly what you are doing. Creating your own for a critical project without previous experience is...usually not a good idea. – nablex Mar 04 '14 at 12:26
  • Thanks for the input. I've thought of that, but couldn't find the source code in github for this version of knowledge-api of drools code base any more. This article here http://mailinator.blogspot.com.au/2009/06/beautiful-race-condition.html explains the HashMap .put causing infinite loop which is similar to the CachingLoader in Drools implementation of CompositeClassLoader. This is similar issue with Drools http://drools.46999.n3.nabble.com/rules-users-Getting-infinite-loops-even-with-limitation-of-fires-td4024922.html. I would have thought it's known issue but drools team haven't fixed. – Tin Ng Mar 04 '14 at 21:28
  • I've only scanned the provided links (no time to read them fully now) but it appears that no bugs were actually reported. Even if they are reported, it may not be high priority, however if you provide the fix (and a testcase for it), something like this usually gets accepted. I scanned github real quick and I found this link: https://github.com/droolsjbpm/droolsjbpm-knowledge/tree/5.6.x. Is this the component/version you were looking for? – nablex Mar 05 '14 at 06:04
  • Thanks again. I actually found the source link a bit earlier during the day and haven't got time to add as a comment here. The thing is it's a multi-threading issue, it's hard to create a test case for it. I've tried to repeat it in our environments, but it hasn't happened. I understand you haven't got time to look at the code closely, but this line here classLoaderResultMap.put( name, cls ); cause an infinitive loop when multi threads cause a resize of the map (as this map was not a ConcurrentHashMap). – Tin Ng Mar 05 '14 at 10:15

0 Answers0