-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Lei,
Lei Gu wrote: > Multi-thread concurrency issue > > During our concurrency testing, we observed NullPointer exceptions being > thrown when two people hit the same page at the same time for the first > time. Upon further investigation, it turns out that we need to > synchronize the init method on ASTDirective, ASTSetDirective, and render > method on ASTSetDirective, and VelocimacroProxy. > > > > Basically, the problem is introduced as the following; when two threads > attempts to parse and render the same template at the same time. Thread1 > finishes parsing first and proceeds to the render method call, while > thread 2 is still busy parsing and will overwrite the existing parse > tree that is being used by thread 1 for rendering purpose. Thus under > certainly condition a NullPointer exception will be thrown. It sounds to me like we should synchronize at a higher level to avoid double-parsing, instead of synchronizing the low-level methods in order to avoid any ill-effects of double-parsing. I must admit that I don't know anything specific about the classes mentioned above, but they sound like they are part of the AST itself. I would imagine that serializing access inside getTemplate (based upon the template stored within Velocity's template cache, not the cache itself) would be cleaner and would result in less wasted effort during runtime. Forgive me if I've got this all wrong ;) - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGDl1G9CaO5/Lv0PARAjjeAJ9AhEdyUbyJ+vN5zaa6lWLOvItzTACePd04 oHl+PVMOBOi/7fkW5mZLekw= =wEn7 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
