Author: shawkins
Date: 2011-02-01 09:59:38 -0500 (Tue, 01 Feb 2011)
New Revision: 2892
Modified:
branches/7.1.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java
Log:
TEIID-1456 adding a check for exceptions to resultsetimpl
Modified: branches/7.1.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2011-01-31
21:12:16 UTC (rev 2891)
+++ branches/7.1.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2011-02-01
14:59:38 UTC (rev 2892)
@@ -48,6 +48,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import java.util.logging.Level;
import java.util.logging.Logger;
import org.teiid.client.ResultsMessage;
@@ -146,6 +147,9 @@
rmetadata = new FilteredResultsMetadata(rmetadata, resultColumns);
}
this.fetchSize = statement.getFetchSize();
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Creating ResultSet requestID: " + requestID + " beginRow:
" + resultsMsg.getFirstRow() + " resultsColumns: " + resultColumns + "
parameters: " + parameters); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
}
public void setMaxFieldSize(int maxFieldSize) {
@@ -356,7 +360,7 @@
}
public Batch requestBatch(int beginRow) throws SQLException{
- logger.fine("CursorResultsImpl.requestBatch] thread name: " +
Thread.currentThread().getName() + " requestID: " + requestID + " beginRow:
" + beginRow ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ logger.finer("requestBatch requestID: " + requestID + " beginRow:
" + beginRow ); //$NON-NLS-1$ //$NON-NLS-2$
checkClosed();
try {
ResultsFuture<ResultsMessage> results =
statement.getDQP().processCursorRequest(requestID, beginRow, fetchSize);
@@ -365,6 +369,11 @@
timeoutSeconds = Integer.MAX_VALUE;
}
ResultsMessage currentResultMsg = results.get(timeoutSeconds,
TimeUnit.SECONDS);
+
+ if (currentResultMsg.getException() != null) {
+ throw TeiidSQLException.create(currentResultMsg.getException());
+ }
+
this.accumulateWarnings(currentResultMsg);
return getCurrentBatch(currentResultMsg);
} catch (TeiidProcessingException e) {
Modified: branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java
===================================================================
--- branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java 2011-01-31
21:12:16 UTC (rev 2891)
+++ branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java 2011-02-01
14:59:38 UTC (rev 2892)
@@ -41,6 +41,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
+import org.mockito.Mockito;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
@@ -696,6 +697,19 @@
assertTrue(rs.previous());
}
}
+
+ @Test(expected=TeiidSQLException.class) public void testResultsMessageException()
throws Exception {
+ ResultsMessage resultsMsg = exampleMessage(exampleResults1(1), new String[] {
"IntNum" }, new String[] { JDBCSQLTypeInfo.INTEGER }); //$NON-NLS-1$
+ resultsMsg.setFinalRow(-1);
+ ResultsMessage next = new ResultsMessage();
+ next.setException(new Throwable());
+ ResultsFuture<ResultsMessage> rf = new
ResultsFuture<ResultsMessage>();
+ rf.getResultsReceiver().receiveResults(next);
+ Mockito.stub(statement.getDQP().processCursorRequest(0, 2, 0)).toReturn(rf);
+ ResultSetImpl cs = new ResultSetImpl(resultsMsg, statement, null, 2);
+ cs.next();
+ cs.next();
+ }
static ResultSetImpl helpTestBatching(StatementImpl statement, int fetchSize, int
batchLength,
int totalLength) throws InterruptedException, ExecutionException,
Show replies by date