|
|
|
@ -3,6 +3,7 @@ package org.gcube.data.streams.adapters;
|
|
|
|
|
import gr.uoa.di.madgik.grs.buffer.IBuffer.Status;
|
|
|
|
|
import gr.uoa.di.madgik.grs.reader.ForwardReader;
|
|
|
|
|
import gr.uoa.di.madgik.grs.reader.GRS2ReaderException;
|
|
|
|
|
import gr.uoa.di.madgik.grs.record.GRS2ExceptionWrapper;
|
|
|
|
|
import gr.uoa.di.madgik.grs.record.Record;
|
|
|
|
|
import gr.uoa.di.madgik.grs.record.exception.GRS2UncheckedException;
|
|
|
|
|
|
|
|
|
@ -42,7 +43,7 @@ public class ResultsetStream<E extends Record> extends LookAheadStream<E> {
|
|
|
|
|
private RuntimeException lookAheadFailure;
|
|
|
|
|
|
|
|
|
|
private ForwardReader<E> reader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private E record;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -75,23 +76,18 @@ public class ResultsetStream<E extends Record> extends LookAheadStream<E> {
|
|
|
|
|
try {
|
|
|
|
|
if (lookAheadFailure!=null)
|
|
|
|
|
throw lookAheadFailure;
|
|
|
|
|
else
|
|
|
|
|
try {
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
catch(GRS2UncheckedException e) {
|
|
|
|
|
|
|
|
|
|
else if (record instanceof GRS2ExceptionWrapper){
|
|
|
|
|
//get underlying cause
|
|
|
|
|
Throwable cause = e.getCause();
|
|
|
|
|
Throwable cause = ((GRS2ExceptionWrapper)record).getEx().getCause();
|
|
|
|
|
|
|
|
|
|
//rewrap checked cause as appropriate to this layer
|
|
|
|
|
if (cause instanceof RuntimeException)
|
|
|
|
|
throw (RuntimeException) cause;
|
|
|
|
|
else
|
|
|
|
|
throw new StreamException(cause);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
} else return record;
|
|
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
lookAheadFailure=null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -121,9 +117,8 @@ public class ResultsetStream<E extends Record> extends LookAheadStream<E> {
|
|
|
|
|
record = reader.get(timeout, timeoutUnit );
|
|
|
|
|
} catch (GRS2ReaderException e) {
|
|
|
|
|
lookAheadFailure = new RuntimeException(e);
|
|
|
|
|
lookAheadFailure.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (reader.getStatus()!=Status.Close && record == null) {
|
|
|
|
|
if (reader.getStatus()==Status.Open)
|
|
|
|
|
lookAheadFailure = new RuntimeException("Timeout occurred reading the resultSet");
|
|
|
|
@ -131,7 +126,7 @@ public class ResultsetStream<E extends Record> extends LookAheadStream<E> {
|
|
|
|
|
lookAheadFailure = new RuntimeException("ResultSet disposed");
|
|
|
|
|
return true;
|
|
|
|
|
} else return record!=null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|