Change in ovirt-engine[master]: core: make postConstruct final

masayag at redhat.com masayag at redhat.com
Thu May 21 12:20:49 UTC 2015


Moti Asayag has submitted this change and it was merged.

Change subject: core: make postConstruct final
......................................................................


core: make postConstruct final

Consider the following case:
Class A {
  @PostConstruct
  protected void foo() {}
}
Class B extends A {
  @Override
  @PostConstruct
  protected void foo() {}
}

JBOSS 7.1.1: when instantiate class B, B#foo will be called twice. This
seems to be a bug in JBOSS.
JBOSS EAP 6.3: when instantiate class B, B#foo will be called only once.

Because of Ibf9cdd60, we have @PostConstruct on postConstruct methods in
commands as well as in the CommandBase, so we have the structure above,
thus in JBOSS 7.1.1 the postConstruct methods are called multiple times.

This patch introduces a different approach where the postConstruct
method that is annotated with @PostConstruct is declared as final in
CommandBase, and calls CommandBase#init which is the method that should
be overridden by commands and does not need to be annotated with
@PostConstruct.

Change-Id: I8340d8348b298fec0c73bf93b7411a149e9fe8c0
Signed-off-by: Arik Hadas <ahadas at redhat.com>
---
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommandBase.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmFromConfigurationCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/hostdeploy/UpgradeHostCommand.java
9 files changed, 21 insertions(+), 35 deletions(-)

Approvals:
  Jenkins CI: Looks good to me, but someone else must approve
  Moti Asayag: Looks good to me, approved
  Arik Hadas: Verified



-- 
To view, visit https://gerrit.ovirt.org/41212
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8340d8348b298fec0c73bf93b7411a149e9fe8c0
Gerrit-PatchSet: 3
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <ahadas at redhat.com>
Gerrit-Reviewer: Arik Hadas <ahadas at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Peřina <mperina at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan at redhat.com>
Gerrit-Reviewer: Moti Asayag <masayag at redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourfali at redhat.com>
Gerrit-Reviewer: Roy Golan <rgolan at redhat.com>
Gerrit-Reviewer: automation at ovirt.org



More information about the Engine-commits mailing list