tballison commented on code in PR #3149:
URL: https://github.com/apache/tika/pull/3149#discussion_r3970103609


##########
tika-core/src/test/java/org/apache/tika/utils/ProcessUtilsTest.java:
##########
@@ -133,4 +134,21 @@ public void 
testCheckCommandCustomTimeoutBoundsASlowCommand() {
         assertTrue(elapsed < 4_000,
                 "checkCommandWithTimeout must honor its own timeout, not the 
default; took " + elapsed + "ms");
     }
+
+    @Test
+    public void testExecuteFailsFastIfTimeoutIsZero() throws Exception {
+        assumeFalse(SystemUtils.IS_OS_WINDOWS);
+
+        ProcessBuilder pb = new ProcessBuilder("sleep", "5");
+        ParseContext context = new ParseContext();
+        context.set(TimeoutLimits.class, new TimeoutLimits(0, 0));
+
+        long start = System.currentTimeMillis();
+        FileProcessResult result = ProcessUtils.execute(pb, context, 5_000L, 
1000, 1000);
+        long elapsed = System.currentTimeMillis() - start;
+
+        assertTrue(result.isTimeout(), "a process with a 0 timeout should 
timeout immediately without starting");
+        assertEquals(0, result.getGrantedTimeoutMillis(), "the process should 
not have been granted any timeout; got " + result.getGrantedTimeoutMillis() + 
"ms");
+        assertTrue(elapsed < 4_000, "fast path should return without spawning; 
took " +  elapsed + "ms");

Review Comment:
   This is legit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to