Closed GoogleCodeExporter closed 9 years ago
httpCounter is not supposed to be null when doFilter is called. And doFilter is
not supposed to be called before init has initialized httpCounter. And in
general, the destroy method of the same class "is only called once all threads
within the filter's doFilter method have exited".
But, the destroy method sets httpCounter to null.
And it may also happen after a timeout in the http requests, that Jetty calls
the destroy method before the end of all doFilter calls, when the webapp is
undeployed or redeployed.
And so, there is the NPE when the doFilter calls finally end.
The webapp was undeployed anyway.
I have made a change in trunk (revision 3095) which should fix most if not all
of those exceptions. It is ready for the next release (1.42).
I have made a new build from the current trunk and it is available at:
http://javamelody.googlecode.com/files/javamelody-20121027.jar
Original comment by evernat@free.fr
on 27 Oct 2012 at 10:15
Looking over my logs again, you are correct. These NPE were thrown as the
application was shutting down, not during startup. So my original description
is incorrect.
But I still believe for thread safety the httpCounter field should be declared
volatile. See the "Pattern #2: one-time safe publication" section at this link
for an explanation:
http://www.ibm.com/developerworks/java/library/j-jtp06197/index.html
BTW Javamelody has been invaluable on my current project. Thank you for all
the hard work.
Original comment by colin...@gmail.com
on 30 Oct 2012 at 4:03
Original issue reported on code.google.com by
colin...@gmail.com
on 24 Oct 2012 at 6:07