Skip to content

Commit

Permalink
Inc max runtime from 5 to 15 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
oglimmer committed Jun 8, 2016
1 parent 951d441 commit 8d9c45c
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -26,6 +26,8 @@
*/
public class SandboxContextFactory extends ContextFactory {

private static final int MAX_TIME_IN_SECS = 15;

@Override
protected Context makeContext() {
Context context = new TimeBoxedContext(this);
Expand Down Expand Up @@ -56,12 +58,12 @@ protected void observeInstructionCount(Context cx, int instructionCount) {

TimeBoxedContext mcx = (TimeBoxedContext) cx;
long currentTime = System.currentTimeMillis();
if (currentTime - mcx.startTime > 5 * 1000) {
// More then 10 seconds from Context creation time:
if (currentTime - mcx.startTime > MAX_TIME_IN_SECS * 1000) {
// More then MAX_TIME_IN_SECS seconds from Context creation time:
// it is time to stop the script.
// Throw Error instance to ensure that script will never
// get control back through catch or finally.
throw new RuntimeExceededException(5);
throw new RuntimeExceededException(MAX_TIME_IN_SECS);
}
}

Expand Down

0 comments on commit 8d9c45c

Please sign in to comment.