[Dive4elements-commits] [PATCH] Datacage: Fix potential connection leak to SedDB

Wald Commits scm-commit at wald.intevation.org
Mon Apr 8 12:07:47 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1365415663 -7200
# Node ID b75005269a6cb48e1e81b5afe71ea5ab6357aebe
# Parent  1827798ca53f71fce16d0aff26e50c92d61e8f5d
Datacage: Fix potential connection leak to SedDB.

diff -r 1827798ca53f -r b75005269a6c flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java	Mon Apr 08 11:24:39 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java	Mon Apr 08 12:07:43 2013 +0200
@@ -20,6 +20,7 @@
 import org.w3c.dom.Node;
 
 import org.hibernate.Session;
+import org.hibernate.SessionFactory;
 
 import org.hibernate.jdbc.Work;
 
@@ -29,7 +30,7 @@
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 
-import de.intevation.flys.backend.SedDBSessionHolder;
+import de.intevation.flys.backend.SessionFactoryProvider;
 import de.intevation.flys.backend.SessionHolder;
 
 import de.intevation.artifactdatabase.data.StateData;
@@ -218,26 +219,33 @@
                     (Connection)null);
             }
         });
-        /*
         systemSession.doWork(new Work() {
             @Override
             public void execute(final Connection systemConnection)
             throws SQLException
             {
-                SedDBSessionHolder.HOLDER.get().doWork(new Work() {
-                    @Override
-                    public void execute(Connection sedDBConnection)
-                    throws SQLException
-                    {
-                        recommend(
-                            parameters, userId, result,
-                            systemConnection,
-                            sedDBConnection);
-                    }
-                });
+                SessionFactory sedDBFactory =
+                    SessionFactoryProvider.getSedDBSessionFactory();
+
+                Session sedDBSession = sedDBFactory.openSession();
+                try {
+                    sedDBSession.doWork(new Work() {
+                        @Override
+                        public void execute(Connection sedDBConnection)
+                        throws SQLException
+                        {
+                            recommend(
+                                parameters, userId, result,
+                                systemConnection,
+                                sedDBConnection);
+                        }
+                    });
+                }
+                finally {
+                    sedDBSession.close();
+                }
             }
         });
-        */
     }
 
     public void recommend(


More information about the Dive4elements-commits mailing list