java - Why is my process hanging at input.readLine()? -


i have utility jmeter sends request , utility sends response jmeter. when load increases, utility shuts down "exception_access_violation".

since error, not able handle in catch block. made second utility restart first utility when error occurs. below code of second, restart, utility. in second utility's code, @ second while, program hangs. how detect , restart process?

public static void main(string[] args) {     string line = null;     string currpid = null;     try     {         while(true)         {             process process = runtime.getruntime().exec("java -xx:+heapdumponoutofmemoryerror -xms250m -xmx500m -xx:errorfile=nul ws ");             bufferedreader input = new bufferedreader(new inputstreamreader(process.getinputstream()));             while ((line = input.readline()) != null) //program stucks @ line             {                 if(line.trim().length() != 0)                 {                     if(line.startswith("pid"))                     {                         currpid = line.substring(line.indexof("@")+1);                     }                 }             }             system.out.println("ended");         }     }     catch(exception e)     {         e.printstacktrace();     } } 

i analysed process through jvisualvm found 2 java process in running mode when start second(restart) utility. can see first utility restarting regularly because pid changing in jvisualvm , same happening in task manager. going on manner.

after sometime found 1 process in jvisualvm ie second(restart) utility. means first utility jvm crashed guessing not sure. unusual happening here. because if jvm crashed should restarted. opened task manager , found first utility pid exists there not changing happening in starting. if kill process(first utility) explicitly task manager. seconds utility again restarts first utility same thing happens again, after time first utility disappeared jvisualvm, exists in taskmanager , delete process taskmanager. needs do?

your problem hanging appears @ call readline.

readline reading lines. method not return until call sure end of line has been reached. expects either newline character or complete cease of communications.

is first utility not sending new line char?

does first utility fail close stream?

your while call hang indefinitely if answer both questions yes.

you might better off consuming custom implementation of scanner class.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -