# HG changeset patch
# User Augusto Mauch <augusto.mauch@openbravo.com>
# Date 1499072654 -7200
#      Mon Jul 03 11:04:14 2017 +0200
# Node ID 2c2ecb5175ba7670cfec3a7f3fff511173d83be8
# Parent  76db46a05b34be9120287a2b23f6cb4613f46166
Fixes issue 36384: Fixes connection leak in ServerStateBackground

Commits the connection outside the for loop, to ensure the connections is commited even if there are no store server to be pinged.

diff --git a/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java b/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java
--- a/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java
+++ b/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java
@@ -455,10 +455,9 @@
               log4j.error("Error when pinging server " + srv.getMobileServerKey(), logIt);
               OBDal.getInstance().rollbackAndClose();
             }
-          } else {
-            OBDal.getInstance().commitAndClose();
           }
         }
+        OBDal.getInstance().commitAndClose();
       } catch (JSONException e) {
         throw new OBException(e);
       } finally {
