Guarantees around Servlet Filter initialization that sets an instance variable?

"Ludwig, Mark via Concurrency-interest" <[email protected]> Wed, 15 Apr 2020 20:45:55 +0000
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <BC5672F8AD4C054BAF167C9801500D1A0178F6D155@USSLMMBX004.net.plm.eds.com>
Greetings,

I hope this is a suitable topic for this list.

We are wondering if we need to arrange for some explicit synchronization in a Servlet Filter's doFilter() method to safely refer to an instance variable that was set in the init() method.

We can't find any mention of this, and without forcing memory fences, are concerned that we're asking for trouble downstream somewhere.

(I think this works, consistently, in practice, "by accident," because there is enough synchronization required between when the container instantiates the filter and calls init() in one thread and when the first doFilter() call comes along in a worker thread.  It seems to me that just having a worker thread pick up a request from a shared queue involves synchronization that "covers" this need in that thread.)

Thanks,

Mark Ludwig

Siemens Digital Industries Software
Lifecycle Collaboration
5939 Rice Creek Parkway
Shoreview, MN  55126 United States
Tel.      :+1 (651) 855-6140
Fax      :+1 (651) 855-6280
[email protected] <mailto:[email protected]>

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest