tag:blogger.com,1999:blog-5701415790759755571.post1664006158566834428..comments2024-03-22T08:17:02.275+01:00Comments on Niklas' Blog: Your web applications work - by sheer coincidence!Niklas Schlimmhttp://www.blogger.com/profile/12402045792243894660noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5701415790759755571.post-24009763085493712142011-12-03T20:08:51.256+01:002011-12-03T20:08:51.256+01:00@Anonymous
Thx for the comment. I do think your si...@Anonymous<br />Thx for the comment. I do think your siggestion makes sense outside an application server. In our case the issue is that the application server continues to start threads that try to compile the same templates ....Niklas Schlimmhttps://www.blogger.com/profile/12402045792243894660noreply@blogger.comtag:blogger.com,1999:blog-5701415790759755571.post-23256677492595455592011-12-03T17:22:53.755+01:002011-12-03T17:22:53.755+01:00I'd suggest using a thread-safe Map of Futures...I'd suggest using a thread-safe Map of Futures generated by submit calls to a ThreadPoolExecutor for Callable XSL compiler objects.<br /><br />java.util.concurrent makes this kind of stuff much easier.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5701415790759755571.post-71327927016948446012011-09-27T17:24:44.391+02:002011-09-27T17:24:44.391+02:00Hi Niklas,
Cool blog! Is there an email address I...Hi Niklas,<br /><br />Cool blog! Is there an email address I can contact you in private?Ilias Tsagklishttps://www.blogger.com/profile/13769934811734511858noreply@blogger.comtag:blogger.com,1999:blog-5701415790759755571.post-73247615225163564542011-09-19T10:41:34.645+02:002011-09-19T10:41:34.645+02:00@Anonymous
the first mustCompile call is necessary...@Anonymous<br />the first mustCompile call is necessary to prevent subsequent threads from locking overhead when THIS template is compiled already. They just return w/o locking anything ... The second call is necessary if two threads are in a race condition after the first mustCompile call. In that case the one thread gets the lock, calls mustCompile and will compile the template 'cause mustCompile returns "true". The second thread was waiting at the lock in the meantime. When the lock is released it enters the locked code block and calls mustCompile, this time it returns "false" and the thread immedieately returns the compiled template ...Niklas Schlimmhttps://www.blogger.com/profile/12402045792243894660noreply@blogger.comtag:blogger.com,1999:blog-5701415790759755571.post-87932012905532687372011-09-18T21:17:20.413+02:002011-09-18T21:17:20.413+02:00This is a VERY impressive post. My name is Jim Man...This is a VERY impressive post. My name is Jim Manico from the OWASP Foundation where we just added your article to our appSec news feed.<br /><br />Would you be interested in converting this and other information into a "OWASP Thread Safety Cheat Sheet" by any chance? We have quite a few already - check out https://www.owasp.org/index.php/Cheat_Sheets and let me know if you would like to join the party. <br /><br />jim@owasp.org<br /><br />Aloha!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5701415790759755571.post-3975708923664530252011-09-18T21:16:25.007+02:002011-09-18T21:16:25.007+02:00Quick question, should'nt the 'mustCompile...Quick question, should'nt the 'mustCompile' method by synchronized, and would that remove the need for calling that method twice?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5701415790759755571.post-75974678045726758582011-09-14T11:49:08.666+02:002011-09-14T11:49:08.666+02:00Hi Niklas,
I remember your comment at the end of ...Hi Niklas,<br /><br />I remember your comment at the end of day 1 of our course: "I only understood half of what you said." and you meant that as a compliment :-)<br /><br />Thank you so much for this write-up - it is a perfect example of why we need to understand concurrency and the effect that concurrency bugs can have.<br /><br />In the Law of the Overstocked Haberdashery (http://www.javaspecialists.eu/archive/Issue149.html), I mentioned this in regard to how many threads are healthy (even if they are inactive): What if a few hundred threads become active suddenly?<br /><br />I'm glad you sorted out your problems and happy that you attended the course just-in-time (JIT).<br /><br />Regards from Crete :-)<br /><br />HeinzHeinz Kabutzhttp://www.javaspecialists.eunoreply@blogger.com