You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2018/03/01 17:08:10 UTC

[Bug 62148] NullPointerException in PumpStreamHandler

https://bz.apache.org/bugzilla/show_bug.cgi?id=62148

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Stefan Bodewig <bo...@apache.org> ---
If you look through Ant's code, you will see PumpStreamHandler is only ever
used from within Execute (apart from invoking the constructor which happens in
a few different places) and inside of this context we "know" outputThread can
never be null. All three setProcess*Stream methods will have been called in
either case before start is called.

Actually technically there may even be a bug that errorThread could be null,
but this doesn't seem to happen in practice or we would have bug reports. The
"err != null" check in setProcessErrorStream looks wrong, neither out nor err
are allowed to be null or we'd end up with NPEs in stop - and in the case of
err == null would  not consume a process' error stream which may block the
process eventually.

The class is not designed to be used outside of the context if Execute at all.
It is public for technical reasons but not expected to be used as an public
API. I hope you are writing a test because you "just" want to write a test and
not because you want to re-use the class outside of Ant.

That being said it certainly wouldn't hurt if the code was more defensive and
verified the implicit preconditions.

-- 
You are receiving this mail because:
You are the assignee for the bug.