Laszlo Hornyak has uploaded a new change for review.

Change subject: engine: use autoclose to clean up vdsdeploy
......................................................................

engine: use autoclose to clean up vdsdeploy

- removed finalize call since it was wait()-ing in GC
- rather than closing vdsdeploy from finalizer, it is now autocloseable
- InstallVdsCommand uses VdsDeploy as autocloseable

Change-Id: I43338f9d2d5bfb36c220f1fd19810f8c7436a543
Signed-off-by: Laszlo Hornyak <lhorn...@redhat.com>
---
M backend/manager/modules/bll/pom.xml
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java
3 files changed, 12 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/90/13090/1

diff --git a/backend/manager/modules/bll/pom.xml 
b/backend/manager/modules/bll/pom.xml
index f21118d..407c6c2 100644
--- a/backend/manager/modules/bll/pom.xml
+++ b/backend/manager/modules/bll/pom.xml
@@ -194,6 +194,14 @@
             </archive>
           </configuration>
         </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <configuration>
+            <source>1.7</source>
+            <target>1.7</target>
+          </configuration>
+        </plugin>
     </plugins>
   </build>
 </project>
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java
index 289638e..8a9cbf2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java
@@ -127,8 +127,8 @@
         }
 
         if (getVds() != null) {
-            VdsDeploy installer = null;
-            try {
+
+            try (final VdsDeploy installer = new VdsDeploy(getVds());) {
                 log.infoFormat(
                     "Before Installation host {0}, {1}",
                     getVds().getId(),
@@ -136,7 +136,6 @@
                 );
 
                 T parameters = getParameters();
-                installer = new VdsDeploy(getVds());
                 installer.setCorrelationId(getCorrelationId());
                 installer.setReboot(parameters.isRebootAfterInstallation());
                 switch (getVds().getVdsType()) {
@@ -185,11 +184,6 @@
                 setSucceeded(false);
                 _failureMessage = getErrorMessage(e.getMessage());
                 addCustomValue("FailedInstallMessage", _failureMessage);
-            }
-            finally {
-                if (installer != null) {
-                    installer.close();
-                }
             }
             return;
         }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java
index e3c262a..ac14db8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java
@@ -68,7 +68,7 @@
  * The installer environment is set according to the ovirt-host-deploy
  * documentation.
  */
-public class VdsDeploy implements SSHDialog.Sink {
+public class VdsDeploy implements SSHDialog.Sink, AutoCloseable {
 
     private static final int THREAD_JOIN_TIMEOUT = 20 * 1000; // milliseconds
     private static final String IPTABLES_CUSTOM_RULES_PLACE_HOLDER = 
"@CUSTOM_RULES@";
@@ -83,7 +83,7 @@
     private MachineDialogParser _parser;
     private final InstallerMessages _messages;
 
-    private VDS _vds;
+    private final VDS _vds;
     private boolean _isNode = false;
     private boolean _reboot = false;
     private String _correlationId = null;
@@ -802,14 +802,6 @@
                 new File(Config.<String> 
GetValue(ConfigValues.BootstrapPackageDirectory))
             );
         }
-    }
-
-    /**
-     * Destructor.
-     */
-    @Override
-    public void finalize() {
-        close();
     }
 
     /**


--
To view, visit http://gerrit.ovirt.org/13090
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43338f9d2d5bfb36c220f1fd19810f8c7436a543
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Laszlo Hornyak <lhorn...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to