dev@glassfish.java.net

Re: Findbugs exception

From: Liang Zhao <liang.x.zhao_at_oracle.com>
Date: Fri, 19 Apr 2013 19:06:08 +0800

Is it available to move
>
> controller = controllerProvider.get();

to constructor so that it will be initialized only once?

Sent from my iPhone

On Apr 19, 2013, at 6:42 PM, John Wells <john.wells_at_oracle.com> wrote:

> I would like an exception for the following "findbugs" find:
>
> I have a method like this:
>
> private RunLevelController getController() {
> if (controller != null) return controller;
>
> synchronized (this) {
> if (controller != null) return controller;
>
> controller = controllerProvider.get();
> return controller;
> }
> }
>
> What I get from findbugs is this:
>
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:590: DC_DOUBLECHECK: Possible doublecheck on com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller in com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.getController()
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:590: IS2_INCONSISTENT_SYNC: Inconsistent synchronization of com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller; locked 57% of time
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:590: IS2_INCONSISTENT_SYNC: Inconsistent synchronization of com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller; locked 57% of time
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:593: IS2_INCONSISTENT_SYNC: Inconsistent synchronization of com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller; locked 57% of time
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:593: IS2_INCONSISTENT_SYNC: Inconsistent synchronization of com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller; locked 57% of time
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:595: IS2_INCONSISTENT_SYNC: Inconsistent synchronization of com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller; locked 57% of time
> jwells: nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java:596: IS2_INCONSISTENT_SYNC: Inconsistent synchronization of com.sun.enterprise.v3.server.AppServerStartup$AppInstanceListener.controller; locked 57% of time
>
> This is the only thing in the file that ever sets the controller variable, and the variable never becomes unset. To me this is valid java...
>
> John Wells
> john.wells_at_oracle.comNOSPAM
>
>