[jboss-svn-commits] JBL Code SVN: r18099 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product: rosetta/src/org/jboss/internal/soa/esb/couriers and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jan 25 04:05:42 EST 2008


Author: mark.little at jboss.com
Date: 2008-01-25 04:05:42 -0500 (Fri, 25 Jan 2008)
New Revision: 18099

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/plugins/org.jboss.soa.esb.oracle.aq/src/main/java/org/jboss/soa/esb/oracle/aq/AQUtil.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
Log:
http://jira.jboss.com/jira/browse/JBESB-1515

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/plugins/org.jboss.soa.esb.oracle.aq/src/main/java/org/jboss/soa/esb/oracle/aq/AQUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/plugins/org.jboss.soa.esb.oracle.aq/src/main/java/org/jboss/soa/esb/oracle/aq/AQUtil.java	2008-01-25 06:20:06 UTC (rev 18098)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/plugins/org.jboss.soa.esb.oracle.aq/src/main/java/org/jboss/soa/esb/oracle/aq/AQUtil.java	2008-01-25 09:05:42 UTC (rev 18099)
@@ -138,6 +138,14 @@
         } catch (SQLException e) {
             log.error("caught sqlexception", e);
         } finally {
+            if (rs != null)
+            {
+        	try {
+                    rs.close();
+                } catch (SQLException e) {
+                    if(log.isDebugEnabled()) log.debug("sqlexception while closing resultset", e);
+                }
+            }
             if(statement!=null)
                 try {
                     statement.close();

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2008-01-25 06:20:06 UTC (rev 18098)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2008-01-25 09:05:42 UTC (rev 18099)
@@ -236,58 +236,71 @@
 				throw new CourierException("Could not determine transaction association!");
 			}
 			
+			ResultSet RS = null;
+			
 			try
-            {
-                ResultSet RS = getRowList();
+			{
+			    RS = getRowList();
 
-				while (null != RS && RS.next())
-				{
-					String messageId = RS.getString(1);
+			    while (null != RS && RS.next())
+			    {
+				String messageId = RS.getString(1);
 
-					if (null == (result = tryToPickup(messageId)))
-						continue;
-					
-					/*
-					 * If this is fault message, then throw an exception with the contents. With the
-					 * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
-					 */
-					
-					if (Type.isFaultMessage(result))
-					    Factory.createExceptionFromFault(result);
-					
-					return result;
-				}
-            }
+				if (null == (result = tryToPickup(messageId)))
+				    continue;
+
+				/*
+				 * If this is fault message, then throw an exception with the contents. With the
+				 * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
+				 */
+
+				if (Type.isFaultMessage(result))
+				    Factory.createExceptionFromFault(result);
+
+				return result;
+			    }
+			}
 			catch (SQLException e)
 			{
-				_logger.debug("SQL Exception during pickup", e);
-				return null;
+			    _logger.debug("SQL Exception during pickup", e);
+			    return null;
 			}
-                        finally
-                        {
-                            // Added to make sure we release transactions from all paths
-                            if (_conn != null)
-                            {
-                                try
-                                {
-                                	if (!transactional)
-                                		_conn.rollback() ;
-                                }
-                                catch (final SQLException sqle) {} //ignore
-                            }
-                        }
-                        try
-                        {
-                                long lSleep = limit - System.currentTimeMillis();
-                                if (_pollLatency < lSleep)
-                                        lSleep = _pollLatency;
-                                if (lSleep > 0)
-                                        Thread.sleep(lSleep);
-                        }
-                        catch (InterruptedException e)
-                        {
-                                return null;
-                        }
+			finally
+			{
+			    try
+			    {
+        			    if (RS != null)
+        				RS.close();
+			    }
+			    catch (final SQLException ex)
+			    {
+				_logger.warn("SQLException during close of ResultSet.", ex);
+			    }
+			    
+			    // Added to make sure we release transactions from all paths
+			    if (_conn != null)
+			    {
+				try
+				{
+				    if (!transactional)
+					_conn.rollback() ;
+				}
+				catch (final SQLException sqle) {} //ignore
+			    }
+			}
+			
+			try
+			{
+			    long lSleep = limit - System.currentTimeMillis();
+			    if (_pollLatency < lSleep)
+				lSleep = _pollLatency;
+			    if (lSleep > 0)
+				Thread.sleep(lSleep);
+			}
+			catch (InterruptedException e)
+			{
+			    return null;
+			}
 		} while (System.currentTimeMillis() <= limit);
 		return null;
 	} // ________________________________
@@ -303,9 +316,12 @@
 
 		while (_conn != null)
 		{
+		    ResultSet RS = null;
+		    
 			try
 			{
-				ResultSet RS = _conn.execQueryWait(select4UpdateStatement(), 3);
+				RS = _conn.execQueryWait(select4UpdateStatement(), 3);
+				
 				while (RS.next())
 				{
 					Exception eBad = null;
@@ -346,10 +362,22 @@
 			{
 				throw new CourierException(e);
 			}
-			catch (Exception e)
+			catch (Exception ex)
 			{
-				jdbcConnectRetry(e);
+				jdbcConnectRetry(ex);
 			}
+			finally
+			{
+			    try
+			    {
+				if (RS != null)
+				    RS.close();
+			    }
+			    catch (final Exception ex)
+			    {
+				_logger.warn("Could not close ResultSet.", ex);
+			    }
+			}
 		}
 		return null;
 	} // ________________________________

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2008-01-25 06:20:06 UTC (rev 18098)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2008-01-25 09:05:42 UTC (rev 18099)
@@ -485,8 +485,11 @@
     protected List<Map<String, Object>> pollForCandidates() {
         List<Map<String, Object>> oResults = new ArrayList<Map<String, Object>>();
         final JdbcCleanConn oConn = getDbConn();
+        
+        ResultSet RS = null;
+        
         try {
-            ResultSet RS = oConn.execQueryWait(_PSscan, 1);
+            RS = oConn.execQueryWait(_PSscan, 1);
             ResultSetMetaData meta = RS.getMetaData();
             while (RS.next()) {
                 Map<String, Object> row = new HashMap<String, Object>();
@@ -504,6 +507,9 @@
         }
         finally {
             try {
+        	if (RS != null)
+        	    RS.close();
+        	
                 oConn.rollback();
             } catch (final SQLException sqle) {
             	refreshDatasource();

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java	2008-01-25 06:20:06 UTC (rev 18098)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java	2008-01-25 09:05:42 UTC (rev 18099)
@@ -225,18 +225,41 @@
 		try
 		{
 			conn = mgr.getConnection();
-			Statement stmt;
-			ResultSet rs;
-			stmt = conn.createStatement();
-			rs = stmt.executeQuery(sql);
-			
-			while (rs.next()) {
-				URI uid = new URI(rs.getString(1));
-				Message msg = getMessage(uid);
-				messages.put(uid, msg);
+			Statement stmt = null;
+			ResultSet rs = null;
+			try
+			{
+        			stmt = conn.createStatement();
+        			rs = stmt.executeQuery(sql);
+        			
+        			while (rs.next()) {
+        				URI uid = new URI(rs.getString(1));
+        				Message msg = getMessage(uid);
+        				messages.put(uid, msg);
+        			}
 			}
-			rs.close();
-			stmt.close();
+			finally
+			{
+			    try
+			    {
+        			    if (rs != null)
+        				rs.close();
+			    }
+			    catch (final Exception ex)
+			    {
+				logger.warn("Could not close ResultSet.", ex);
+			    }
+			    
+			    try
+			    {
+        			    if (stmt != null)
+        				stmt.close();
+			    }
+			    catch (final Exception ex)
+			    {
+				logger.warn("Could not close Statement.", ex);
+			    }
+			}
 
 		}
 		catch (Exception e)
@@ -268,19 +291,42 @@
         try
         {
             conn = mgr.getConnection();
-            Statement stmt;
-            ResultSet rs;
-            stmt = conn.createStatement();
-            rs = stmt.executeQuery(sql);
+            Statement stmt = null;
+            ResultSet rs = null;
             
-            while (rs.next()) {
-                URI uid = new URI(rs.getString(1));
-                Message msg = Util.deserialize((Serializable) Encoding.decodeToObject( rs.getString(2)));
-                messages.put(uid, msg);
+            try
+            {
+                stmt = conn.createStatement();
+                rs = stmt.executeQuery(sql);
+                
+                while (rs.next()) {
+                    URI uid = new URI(rs.getString(1));
+                    Message msg = Util.deserialize((Serializable) Encoding.decodeToObject( rs.getString(2)));
+                    messages.put(uid, msg);
+                }
             }
-            rs.close();
-            stmt.close();
-
+            finally
+            {
+        	try
+		    {
+			    if (rs != null)
+				rs.close();
+		    }
+		    catch (final Exception ex)
+		    {
+			logger.warn("Could not close ResultSet.", ex);
+		    }
+		    
+		    try
+		    {
+			    if (stmt != null)
+				stmt.close();
+		    }
+		    catch (final Exception ex)
+		    {
+			logger.warn("Could not close Statement.", ex);
+		    }
+            }
         }
         catch (Exception e)
         {
@@ -401,18 +447,45 @@
     {
         Message message=null;
         String selectSql = "select * from "+tableName+" where uuid=?";
-        PreparedStatement selectStmt = connection.prepareStatement(selectSql);
-        selectStmt.setObject(1, uid.toString());
-        ResultSet rs = selectStmt.executeQuery();
-        if (rs.next()) {
-            try {
-                message = Util.deserialize((Serializable) Encoding.decodeToObject(rs.getString("message")));
-            } catch (Exception e) {
-                throw new MessageStoreException(e);
+        PreparedStatement selectStmt = null;
+        ResultSet rs = null;
+        
+        try
+        {
+            selectStmt = connection.prepareStatement(selectSql);
+            selectStmt.setObject(1, uid.toString());
+            rs = selectStmt.executeQuery();
+            
+            if (rs.next()) {
+                try {
+                    message = Util.deserialize((Serializable) Encoding.decodeToObject(rs.getString("message")));
+                } catch (Exception e) {
+                    throw new MessageStoreException(e);
+                }
             }
         }
-        rs.close();
-        selectStmt.close();
+        finally
+        {
+            try
+	    {
+		    if (rs != null)
+			rs.close();
+	    }
+	    catch (final Exception ex)
+	    {
+		logger.warn("Could not close ResultSet.", ex);
+	    }
+	    
+	    try
+	    {
+		    if (selectStmt != null)
+			selectStmt.close();
+	    }
+	    catch (final Exception ex)
+	    {
+		logger.warn("Could not close Statement.", ex);
+	    }
+        }
         return message;
     }
     
@@ -421,19 +494,46 @@
     {
         Message message=null;
         String selectSql = "select * from "+tableName+" where uuid=? and classification=?";
-        PreparedStatement selectStmt = connection.prepareStatement(selectSql);
-        selectStmt.setObject(1, uid.toString());
-        selectStmt.setObject(2, classification);
-        ResultSet rs = selectStmt.executeQuery();
-        if (rs.next()) {
-            try {
-                message = Util.deserialize((Serializable) Encoding.decodeToObject(rs.getString("message")));
-            } catch (Exception e) {
-                throw new MessageStoreException(e);
+        PreparedStatement selectStmt = null;
+        ResultSet rs = null;
+        
+        try
+        {
+            selectStmt = connection.prepareStatement(selectSql);
+            selectStmt.setObject(1, uid.toString());
+            selectStmt.setObject(2, classification);
+            rs = selectStmt.executeQuery();
+            
+            if (rs.next()) {
+                try {
+                    message = Util.deserialize((Serializable) Encoding.decodeToObject(rs.getString("message")));
+                } catch (Exception e) {
+                    throw new MessageStoreException(e);
+                }
             }
         }
-        rs.close();
-        selectStmt.close();
+        finally
+        {
+            try
+	    {
+		    if (rs != null)
+			rs.close();
+	    }
+	    catch (final Exception ex)
+	    {
+		logger.warn("Could not close ResultSet.", ex);
+	    }
+	    
+	    try
+	    {
+		    if (selectStmt != null)
+			selectStmt.close();
+	    }
+	    catch (final Exception ex)
+	    {
+		logger.warn("Could not close Statement.", ex);
+	    }
+        }
         return message;
     }
     
@@ -441,11 +541,30 @@
         throws SQLException
     {
         String deleteSql = "delete from "+tableName+" where uuid=? and classification=?";
-        PreparedStatement stmt = connection.prepareStatement(deleteSql);
-        stmt.setObject(1, uid.toString());
-        stmt.setObject(2, classification);
-        int result = stmt.executeUpdate();
-        stmt.close();
+        PreparedStatement stmt = null;
+        int result;
+        
+        try
+        {
+            stmt = connection.prepareStatement(deleteSql);
+            
+            stmt.setObject(1, uid.toString());
+            stmt.setObject(2, classification);
+            result = stmt.executeUpdate();
+        }
+        finally
+        {
+            try
+            {
+                if (stmt != null)
+            		stmt.close();
+            }
+            catch (final Exception ex)
+            {
+        	logger.warn("Could not close Statement.", ex);
+            }
+        }
+        
         return result;
     }
     
@@ -453,20 +572,28 @@
         throws SQLException, MessageStoreException
     {
         String sql = "insert into "+tableName+"(uuid, type, message, delivered, classification) values(?,?,?,?,?)";
-        PreparedStatement ps = conn.prepareStatement(sql);
+        PreparedStatement ps = null;
         
-        ps.setString(1, uid.toString());
-        ps.setString(2, message.getType().toString());
-        try {
-            String messageString = Encoding.encodeObject(Util.serialize(message));
-            ps.setString(3, messageString);
-        } catch (Exception e) {
-            throw new MessageStoreException(e);
+        try
+        {
+            ps = conn.prepareStatement(sql);
+            ps.setString(1, uid.toString());
+            ps.setString(2, message.getType().toString());
+            try {
+                String messageString = Encoding.encodeObject(Util.serialize(message));
+                ps.setString(3, messageString);
+            } catch (Exception e) {
+                throw new MessageStoreException(e);
+            }
+            ps.setString(4, "TRUE");
+            ps.setString(5, classification);
+            ps.execute();
         }
-        ps.setString(4, "TRUE");
-        ps.setString(5, classification);
-        ps.execute();
-        ps.close();
+        finally
+        {
+            if (ps != null)
+        	ps.close();
+        }
     }
     
 




More information about the jboss-svn-commits mailing list