Hi,

In June there was a discussion about the problem synchronization in
FilterToBeanProxy, which results in a change in this class: Now the method
doInit() is synchronized.

But this dosn't solve the problem: When the first thread starts executing
doInit() it sets initialized to true. If a second thread gets running before
the first thread ends with doInit() the second thread detects "initialized
is true" and runs in the same NullPointerException, because "delegate" is
still null. The reason is, that the test "if (!initialized)" isn't
synchronized.

I see two solutions for this problem:

1.) Add a method isInitialized(), which is synchronized too and replace "if
(!initialized)" by "if (!isInitialized())". The ugly point in this solution
is, that this synchronization has to take place in the startup phase of a
webapp, but we don't need it after the initialization has finished. But a
synchronized isInitialized() would synchronize each request to this webapp.

2.) Place the statement "initialized = true;" at the end of doInit(). The
advantage of this solution would be that synchronization would be done in
startup phase only. The problem of this solution is, that you can't be sure,
that on every machine the concurrency solution works (see the "Double
Checked Locking" problem, e.g.
http://en.wikipedia.org/wiki/Double-checked_locking
<http://en.wikipedia.org/wiki/Double-checked_locking> ). But I think that
this solution should be ok, because "initialized" is a primitive type (no
object) and because the synchronization is only needed for startup time,
which is normally an issue while development, not after real deployment.

So I would suggest to choose solution 2.).

Regards
Volker

Gruß
Volker

_________________________

Volker Malzahn
FJA Feilmeier & Junker GmbH
Ein Unternehmen der FJH Gruppe
Sachsenring 83
50677 Köln
Tel.: 0221 / 33 80 - 271
Fax: 0221 / 9 32 17 30
Email:  [EMAIL PROTECTED]




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Home: http://acegisecurity.sourceforge.net
Acegisecurity-developer mailing list
Acegisecurity-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer

Reply via email to