ejb - Hanging forever when executing a shell command (Java) -


itemprop = "text">

The code's block block is down, the code almost always works, but sometimes it always hangs for the application. EJB is timer bean.

Actually, it is only hanging once and I can not reproduce it. It has worked in the production for almost 2 years without any problem, but while testing the updated version of the app, the timer slipped after running for a few days and never released the database lock from the last run . Logs clearly show that it has moved somewhere in the block of code below. This is the command 'chmod'.

  Public Zero ShellXAC (string CMD, file workID) {string s = empty; Try {procedure p = runtime.gettime (). Exec (cmd, null, workDir); Int i = p.waitFor (); If (i == 0) {buffrader stdInput = new buffedder (new interstitial reader (pg. Inputstream ()); // When reading the output from the command (s = stdInput.readLine ())! = Null) {logger.debug (s); }} And {buffrader stdErr = new BufferedReader (New InputStreamRedder (P. Jetrestream ()); // When reading the output from the command (s = stdErr.readLine ())! = Null) {logger.debug (s); }}} Hold (exception e) {logger.debug (e); }}  

I am reluctant to amend this code because it has been tested and worked correctly for almost two years. I too can not reproduce this problem, so I will not have any idea that any new written version is any better. But, it is very clear that it is hanging and I do not know what the probability is.

From this issue to goggle, it seems that the block of code executes a shell command To do is quite standard. Is there a known problem with that code?

Thanks

= "Post-text" itemprop = "text">

You need to perform the execution of stdout / err concurrent . Otherwise you will see the behavior that blocks you. See for more information.


Comments