Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Java Interop by

The IBlockingDeref for the reification in clojure.java.process/start is not implemented according to specification in deref doc-string.

The 3-arity IBlockingDeref expects timeout in milliseconds, and that the third argument is a timeout-val. The implementation in clojure.java.process (line 113, linked below) wrongly expects the two arguments to be a timeout with its unit specified in last argument as a java.util.concurrent.TimeUnit. When given some j.u.c.TimeUnit as timeout-val, it will still return nil after the timeout.

Expected: That this implementation of IBlockingDeref always assumes the timeunit to be hardcoded as TimeUnit/MILLISECONDS, and that the given timeout-val is returned if the deref to IBlockingDeref times out.

See clojure/java/process.clj#L113

Looking into what to expect from java.lang.Process.waitFor, the current implementation is quite useful compared to the semantics of the ordinary IBlockingDeref - process timeouts could often be specified in seconds or minutes rather than milliseconds, and the expected return value from .waitFor with timeout is boolean, and no timeout is specified, it is just the exitcode of the Process. Any processing of the return exit codes (or nil on timeout) could quite easily handle nil or a some timeout-val.

However - it is still confusing to embed this functionality in the IBlockingDeref.

1 Answer

0 votes

Thanks! Logged as https://clojure.atlassian.net/browse/CLJ-2865 - we will get that fixed before 1.12 release.