Hello, Having (finally) some free time again I decided to give COCOON-2216 another try. Unfortunately, I wasn't entirely successful with my latest attempt even if there seems to be progress.
Actually, you don't need to follow my previous attempts and comments to understand what's going on with latest patches trying to fix this annoying bug. Current problem is that it looks like I get into some race conditions but I have no idea how to track them. Little background: the problem was with the ObjectModel that was shared between child threads leading to illegal state. The solution was to clone ObjectModel object so separate instances are used across different child threads. I decided to bind ObjectModel to Environment (as it felt rather natural to do so) and to implement cloning in AbstractCocoonRunnable. Moreover, there is a custom bean factory that returns an ObjectModel instance obtained from the current Environment. Additionally, this instance is being wrapped by a proxy so we can be sure that other beans always reference correct instance of the ObjectModel. You can find my modifications here: http://github.com/gkossakowski/apache-cocoon/commits/COCOON-2216-multi-thread-simple If you wonder why this is uploaded to Github the answer is rather simple - I believe that it's better way to share patches so they are available for online browsing along with commit messages before they get committed to trunk. Imran provided us a test-case that nicely exhibits problems with both our implementation in Cocoon's trunk (or lack of it) and these race conditions in my implementation. The code is available here: https://issues.apache.org/jira/secure/attachment/12391183/test-block.zip (referenced from https://issues.apache.org/jira/browse/COCOON-2216) How to reproduce: 1. Download patched Cocoon sources from http://github.com/gkossakowski/apache-cocoon/commits/COCOON-2216-multi-thread-simple and compile them. 2. Download test-block, run it using mvn jetty:run. 3. Point your browser to http://localhost:8888/test-block/index.html 4. Check console if information about exceptions are being printed out. I would kindly ask multi-thread-programming gurus to have a look at this problem as I feel like running out of ideas and energy... -- Best regards, Grzegorz Kossakowski
