Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc6941a

Browse files
committed
Change new option to an actual timeout value
Default is 0. In that case, there is no timeout at all. Timeout is in seconds.
1 parent 4bef1ed commit dc6941a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/org/utplsql/api/TestRunner.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ public TestRunner addTags(Collection<String> tags) {
145145
return this;
146146
}
147147

148-
public TestRunner catchOraStuck( boolean catchOraStuck ) {
149-
this.options.catchOraStuck = catchOraStuck;
148+
public TestRunner oraStuckTimeout(Integer oraStuckTimeout ) {
149+
this.options.oraStuckTimeout = oraStuckTimeout;
150150
return this;
151151
}
152152

@@ -218,7 +218,7 @@ public void run(Connection conn) throws SQLException {
218218

219219
TestRunnerStatement testRunnerStatement = null;
220220
try {
221-
testRunnerStatement = ( options.catchOraStuck ) ? initStatementWithTimeout(conn) : initStatement(conn);
221+
testRunnerStatement = ( options.oraStuckTimeout > 0 ) ? initStatementWithTimeout(conn, options.oraStuckTimeout) : initStatement(conn);
222222
logger.info("Running tests");
223223
testRunnerStatement.execute();
224224
logger.info("Running tests finished.");
@@ -236,15 +236,15 @@ private TestRunnerStatement initStatement( Connection conn ) throws SQLException
236236
return compatibilityProxy.getTestRunnerStatement(options, conn);
237237
}
238238

239-
private TestRunnerStatement initStatementWithTimeout( Connection conn ) throws OracleCreateStatmenetStuckException, SQLException {
239+
private TestRunnerStatement initStatementWithTimeout( Connection conn, int timeout ) throws OracleCreateStatmenetStuckException, SQLException {
240240
ExecutorService executor = Executors.newSingleThreadExecutor();
241241
Callable<TestRunnerStatement> callable = () -> compatibilityProxy.getTestRunnerStatement(options, conn);
242242
Future<TestRunnerStatement> future = executor.submit(callable);
243243

244244
// We want to leave the statement open in case of stuck scenario
245245
TestRunnerStatement testRunnerStatement = null;
246246
try {
247-
testRunnerStatement = future.get(2, TimeUnit.SECONDS);
247+
testRunnerStatement = future.get(timeout, TimeUnit.SECONDS);
248248
} catch (TimeoutException e) {
249249
logger.error("Detected Oracle driver stuck during Statement initialization");
250250
executor.shutdownNow();

src/main/java/org/utplsql/api/TestRunnerOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TestRunnerOptions {
3030
public boolean randomTestOrder = false;
3131
public Integer randomTestOrderSeed;
3232
public final Set<String> tags = new LinkedHashSet<>();
33-
public boolean catchOraStuck = false;
33+
public Integer oraStuckTimeout = 0;
3434

3535
public String getTagsAsString() {
3636
return String.join(",", tags);

0 commit comments

Comments
 (0)