[teiid-commits] teiid SVN: r4192 - in trunk: test-integration/common/src/test/java/org/teiid/systemmodel and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Jun 20 15:49:34 EDT 2012


Author: shawkins
Date: 2012-06-20 15:49:33 -0400 (Wed, 20 Jun 2012)
New Revision: 4192

Modified:
   trunk/client/src/main/java/org/teiid/jdbc/NonBlockingRowProcessor.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
Log:
TEIID-2081 fix for continuous close on the client side

Modified: trunk/client/src/main/java/org/teiid/jdbc/NonBlockingRowProcessor.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/NonBlockingRowProcessor.java	2012-06-20 15:57:10 UTC (rev 4191)
+++ trunk/client/src/main/java/org/teiid/jdbc/NonBlockingRowProcessor.java	2012-06-20 19:49:33 UTC (rev 4192)
@@ -22,6 +22,7 @@
  
 package org.teiid.jdbc;
 
+import java.util.concurrent.ExecutionException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -56,6 +57,10 @@
 				public void run() {
 					while (true) {
 						try {
+							if (stmt.isClosed()) {
+								callback.onComplete(stmt);
+								break;
+							}
 							ResultsFuture<Boolean> hasNext = resultSet.submitNext();
 							synchronized (hasNext) {
 								if (!hasNext.isDone()) {
@@ -77,6 +82,7 @@
 							}
 						} catch (Exception e) {
 							onException(e);
+							break;
 						}
 					}
 				}
@@ -107,6 +113,12 @@
 	}
 
 	private void onException(Exception e) {
+		if (e instanceof ExecutionException) {
+			ExecutionException ee = (ExecutionException)e;
+			if (ee.getCause() instanceof Exception) {
+				e = (Exception)ee.getCause();
+			}
+		}
 		try {
 			callback.onException(stmt, e);
 		} catch (Exception e1) {

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java	2012-06-20 15:57:10 UTC (rev 4191)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java	2012-06-20 19:49:33 UTC (rev 4192)
@@ -32,7 +32,9 @@
 import java.sql.Statement;
 import java.sql.Types;
 
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.teiid.client.util.ResultsFuture;
 import org.teiid.core.util.UnitTestUtil;
@@ -50,6 +52,17 @@
 @SuppressWarnings("nls")
 public class TestSystemVirtualModel extends AbstractMMQueryTestCase {
 	private static final String VDB = "PartsSupplier"; //$NON-NLS-1$
+	
+	private static FakeServer server;
+    
+    @BeforeClass public static void setup() throws Exception {
+    	server = new FakeServer(true);
+    	server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+    }
+    
+    @AfterClass public static void teardown() throws Exception {
+    	server.stop();
+    }
 
 	public TestSystemVirtualModel() {
 		// this is needed because the result files are generated
@@ -58,8 +71,6 @@
 	}
 	
     @Before public void setUp() throws Exception {
-    	FakeServer server = new FakeServer(true);
-    	server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
     	this.internalConnection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$	
    	}
    
@@ -186,8 +197,8 @@
 	}
 	
 	@Test public void testAsynch() throws Exception {
-		Statement s = this.internalConnection.createStatement();
-		TeiidStatement ts = s.unwrap(TeiidStatement.class);
+		Statement stmt = this.internalConnection.createStatement();
+		TeiidStatement ts = stmt.unwrap(TeiidStatement.class);
 		final ResultsFuture<Integer> result = new ResultsFuture<Integer>(); 
 		ts.submitExecute("select * from SYS.Schemas", new StatementCallback() {
 			int rowCount;
@@ -210,8 +221,8 @@
 	}
 	
 	@Test public void testAsynchContinuous() throws Exception {
-		Statement s = this.internalConnection.createStatement();
-		TeiidStatement ts = s.unwrap(TeiidStatement.class);
+		Statement stmt = this.internalConnection.createStatement();
+		TeiidStatement ts = stmt.unwrap(TeiidStatement.class);
 		final ResultsFuture<Integer> result = new ResultsFuture<Integer>(); 
 		ts.submitExecute("select * from SYS.Schemas", new StatementCallback() {
 			int rowCount;
@@ -225,7 +236,7 @@
 			
 			@Override
 			public void onException(Statement s, Exception e) {
-				result.getResultsReceiver().receiveResults(rowCount);
+				result.getResultsReceiver().exceptionOccurred(e);
 			}
 			
 			@Override



More information about the teiid-commits mailing list