Skip to content

Commit 2ed2038

Browse files
committed
Cleanup timeout
1 parent 504eda8 commit 2ed2038

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

src/main/java/rife/bld/extension/ExecOperation.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
5252
private boolean inheritIO_ = true;
5353
@NonNull
5454
private Consumer<String> outputConsumer_ = DEFAULT_OUTPUT_CONSUMER;
55-
private int timeout_ = ProcessExecutor.DEFAULT_TIMEOUT_SECONDS;
55+
private long timeout_ = ProcessExecutor.DEFAULT_TIMEOUT_SECONDS;
5656
private File workDir_;
5757

5858
@Override
@@ -530,13 +530,13 @@ public ExecOperation outputConsumer(@NonNull Consumer<String> outputConsumer) {
530530
/**
531531
* Configure the command timeout.
532532
*
533-
* @param timeout The timeout in seconds, must be greater than 0
533+
* @param timeout The timeout in seconds, use a negative number for no timeout
534534
* @return this operation instance
535-
* @throws IllegalArgumentException if timeout is less than or equal to 0
535+
* @throws IllegalArgumentException if timeout is 0
536536
*/
537-
public ExecOperation timeout(int timeout) {
537+
public ExecOperation timeout(long timeout) {
538538
if (timeout <= 0) {
539-
throw new IllegalArgumentException("timeout must be > 0");
539+
throw new IllegalArgumentException("timeout should not be 0; use a negative number for no timeout");
540540
}
541541
timeout_ = timeout;
542542
return this;
@@ -547,7 +547,7 @@ public ExecOperation timeout(int timeout) {
547547
*
548548
* @return the timeout in seconds
549549
*/
550-
public int timeout() {
550+
public long timeout() {
551551
return timeout_;
552552
}
553553

src/test/java/rife/bld/extension/ExecOperationTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,11 @@ void osDetectionDelegatesToSystemTools() {
290290
assertThat(ExecOperation.isMingw()).isEqualTo(SystemTools.isMinGw());
291291
}
292292

293-
@Test
294-
void timeoutNegativeThrows() {
295-
assertThatThrownBy(() -> createBasicExecOperation().timeout(-5))
296-
.isInstanceOf(IllegalArgumentException.class);
297-
}
298-
299293
@Test
300294
void timeoutZeroThrows() {
301295
assertThatThrownBy(() -> createBasicExecOperation().timeout(0))
302296
.isInstanceOf(IllegalArgumentException.class)
303-
.hasMessage("timeout must be > 0");
297+
.hasMessageContaining("timeout should not be 0");
304298
}
305299

306300
@Test

0 commit comments

Comments
 (0)