Skip to content

Commit f990832

Browse files
committed
set default timeout based on running context
1 parent b3eb456 commit f990832

File tree

1 file changed

+7
-3
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/util

1 file changed

+7
-3
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/util/Executor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.util;
@@ -63,7 +63,7 @@ public class Executor {
6363
private final File workingDirectory;
6464
private byte[] stdout;
6565
private byte[] stderr;
66-
private int timeout; // in seconds, 0 means no timeout
66+
private int timeout; // in milliseconds, 0 means no timeout
6767

6868
/**
6969
* Create a new instance of the Executor.
@@ -83,14 +83,18 @@ public Executor(List<String> cmdList) {
8383

8484
/**
8585
* Create a new instance of the Executor with default command timeout value.
86+
* The timeout value will be based on the running context (indexer or web application).
8687
* @param cmdList A list containing the command to execute
8788
* @param workingDirectory The directory the process should have as the
8889
* working directory
8990
*/
9091
public Executor(List<String> cmdList, File workingDirectory) {
92+
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
93+
int timeoutSec = env.isIndexer() ? env.getIndexerCommandTimeout() : env.getInteractiveCommandTimeout();
94+
9195
this.cmdList = cmdList;
9296
this.workingDirectory = workingDirectory;
93-
this.timeout = RuntimeEnvironment.getInstance().getIndexerCommandTimeout() * 1000;
97+
this.timeout = timeoutSec * 1000;
9498
}
9599

96100
/**

0 commit comments

Comments
 (0)