db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1348818 - /db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
Date Mon, 11 Jun 2012 12:30:29 GMT
Author: kristwaa
Date: Mon Jun 11 12:30:29 2012
New Revision: 1348818

URL: http://svn.apache.org/viewvc?rev=1348818&view=rev
Log:
DERBY-5803: Make error handling in xaHelper more explicit 

Make error handling method return an execption and raise it explicitly.
Note that the method may still throw runtime exceptions.

Patch file: derby-5803-1a-explict_throw.diff


Modified:
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java?rev=1348818&r1=1348817&r2=1348818&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java Mon Jun 11
12:30:29 2012
@@ -30,14 +30,12 @@ import java.util.Locale;
 import java.util.Vector;
 
 import javax.transaction.xa.Xid;
-import javax.transaction.xa.XAResource;
 import javax.transaction.xa.XAException;
 import javax.sql.PooledConnection;
 import javax.sql.XAConnection;
 import javax.sql.XADataSource;
 import javax.sql.DataSource;
 import javax.sql.ConnectionPoolDataSource;
-import org.apache.derby.iapi.services.info.JVMInfo;
 
 /*
  * The real xa helper class.  Load this class only if we know the javax classes
@@ -166,7 +164,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch (Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}	
 	}
 
@@ -208,7 +206,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch (Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 	}
 
@@ -228,9 +226,8 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
-		return null;
 	}
 
 	public void CommitStatement(ij parser, Token onePhase, Token twoPhase, 
@@ -243,7 +240,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 	}
 
@@ -255,7 +252,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 	}
 
@@ -267,7 +264,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 	}
 
@@ -279,7 +276,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 	}
 
@@ -293,7 +290,7 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 
 		Vector v = new Vector();
@@ -315,9 +312,8 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
-
 	}
 
 	public void StartStatement(ij parser, int flag, int xid) throws SQLException
@@ -328,16 +324,26 @@ class xaHelper implements xaAbstractHelp
 		}
 		catch(Throwable t)
 		{
-			handleException(t);
+            throw handleException(t);
 		}
 	}
 
-	private void handleException(Throwable t) throws SQLException
+    /**
+     * Handles the given throwable.
+     * <p>
+     * If possible, an {@code SQLException} is returned. Otherwise the
+     * appropriate actions are taken and a {@code RuntimeException} is thrown.
+     *
+     * @param t exception to handle
+     * @return An {@code SQLException}.
+     * @throws RuntimeException if the throwable isn't an {@code SQLException}
+     */
+	private SQLException handleException(Throwable t)
 	{
 		if (t instanceof SQLException)
 		{
 			// let ij handle it
-			throw (SQLException)t;
+            return (SQLException)t;
 		}
 		if (t instanceof XAException)
 		{



Mime
View raw message