dev@glassfish.java.net

FW: patch review request

From: Koper, Dies <diesk_at_fast.au.fujitsu.com>
Date: Tue, 6 Mar 2012 08:58:16 +1100

bump


attached mail follows:



Hi Shing Wai, Amy,

I received the following findbugs report. Please review the patch
attached (for 4.0 trunk).

In short, the code modifies a static variable from a non-static method.
The class wants to lazily initialize something once.
As there is a chance that it is accessed simultaneously from different
threads, I once added a static class member boolean to remember whether
it has been initialized before, and only do the initialization if it
has. The code checking and setting the boolean and the initialization
code is in a synchronized block (sync'ing on the class).

Findbugs says we shouldn't modify static members from an instance, as it
could be confusing (unexpected).
The solution is as simple as moving the code block to a static method:
calling static methods from instance methods is okay.

Thanks,
Dies


> -----Original Message-----
> From: Java Release Engineering
[mailto:java_re_at_dad-s10-10.us.oracle.com]
> Sent: Tuesday, 21 February 2012 1:47 AM
> To: dkoper_at_java.net
> Cc: janey_at_java.net; jill.sato_at_oracle.com; shannon_at_java.net
> Subject: FindBugs LOW PRIORITY errors in GlassFish workspace
>
> Note: *Please read and take action*
>
> This mail contains the fingbugs (http://findbugs.sourceforge.net/) low
level
> errors
> in the lines of code that you last modified.
>
> For additional information, please visit the FindBugs page:
> (http://wikis.oracle.com/display/GlassFish/FindBugs).
>
> Thank you.
>
> Errors:
> ==========================================================
> =======================================
> dkoper: appserver/web/web-
> core/src/main/java/org/apache/catalina/loader/WebappLoader.java:648:
> ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD: Write to static field
> org.apache.catalina.loader.WebappLoader.first from instance method
> org.apache.catalina.loader.WebappLoader.start()