New inspection for correct Process usage?

I recently found this
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6462165
and immediately remembered at least three instances where I fell for that bug.

Would it be possible to add some inspection to alert people to this quite unknown problem?
I am not sure how exactly the inspection should work...

Maybe simply trigger when an instance of Process goes out of scope without its streams properly closed?

Changed "ProcessBuilder" to "Process" - no idea what made me think of the wrong class name.

7 comments

Stephen Friedrich wrote:

and immediately remembered at least three instances where I fell for that bug.


It's not just you: http://www.jetbrains.net/jira/browse/TW-1632 ;)

0

Well you learn something new every day! Many thanks for the heads up
about this, I had no idea you had to do that, may even explain some long
running problems we've been having. Oh, and +10 for the inspection if it
is possible.

N.

Stephen Friedrich wrote:

I recently found this
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6462165
and immediately remembered at least three instances where I fell for that bug.

Would it be possible to add some inspection to alert people to this quite unknown problem?
I am not sure how exactly the inspection should work...

Maybe simply trigger when an instance of ProcessBuilder goes out of scope with its streams properly closed?

0

I like it. Please submit a JIRA request.

I guess this would be the correct way to close all the process streams:

Pretty ugly code if you ask me. Too bad close() throws an IOException.

Bas

0

Thanks. Done that: http://www.jetbrains.net/jira/browse/IDEA-12230

My code always uses a tiny helper method. That's not shorter, yet feels cleaner:

0

On 2007-04-04 00:03:22 +0400, Stephen Friedrich <no_reply@jetbrains.com> said:

I recently found this
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6462165
and immediately remembered at least three instances where I fell for that bug.

Would it be possible to add some inspection to alert people to this
quite unknown problem?
I am not sure how exactly the inspection should work...

Maybe simply trigger when an instance of ProcessBuilder goes out of
scope with its streams properly closed?


Have you guys tried that sample attached to the issue? As the matter of
fact the test doesn't fail under JDK 1.5 and indeed fails under JDK 1.3.
But...
closing all the streams alone doesn't help (process stuck after
creating ~80 subprocesses) and one must call Process.destroy() to fix
the issue completely.

Yet again, everything is OK under 1.5

Max

0

Maxim Shafirov wrote:

Have you guys tried that sample attached to the issue? As the matter of
fact the test doesn't fail under JDK 1.5 and indeed fails under JDK 1.3.


Hmm, I've personally seen the "too many open files" exception from TW-1632 and
already suspected the leak in the execution of "chmod". Maybe the issue "solves"
itself once the Process instances (or their streams) become garbage collected,
but explicitly closing them seems to be a good idea anyway - although there's a
slight chance that it doesn't solve the problem either... :(

Sascha

0

On 2007-04-04 14:53:39 +0400, Sascha Weinreuter
<sascha.weinreuter@NOSPAM-cit.de> said:

Maxim Shafirov wrote:

>> Have you guys tried that sample attached to the issue? As the matter of
>> fact the test doesn't fail under JDK 1.5 and indeed fails under JDK 1.3.


Hmm, I've personally seen the "too many open files" exception from TW-1632 and
already suspected the leak in the execution of "chmod". Maybe the issue
"solves"
itself once the Process instances (or their streams) become garbage collected,
but explicitly closing them seems to be a good idea anyway - although there's a
slight chance that it doesn't solve the problem either... :(

Sascha


This is not a CG/finalization issue either. I modified original sample
so all processes created are held by hard reference and cannot be
collected. Still cannot reproduce the problem under JDK 1.5

0

Please sign in to leave a comment.