Java Class Error: java.io.IOException: pipe is closing

We intermittently get "java.io.IOException: the pipe closes" with the code below. There is a very intermittent nature. Any advice? I tried to replicate this, and when I unplug my machine, I can get this error. This class reads and writes information after a Siebel CRM session.

Here with the Java class code.

private Process _process; private OutputStream _processOut; private ByteArrayOutputStream _sessionOutput; .... _processOut = _process.getOutputStream(); _sessionOutput = new ByteArrayOutputStream(); .... public void writeCommand(String command) throws IOException { _processOut.write(command.getBytes()); _processOut.flush(); _sessionOutput.write(command.getBytes()); } 

Here with the actual error:

 java.io.IOException: The pipe is being closed at java.io.FileOutputStream.writeBytes(Native Method) at java.io.FileOutputStream.write(FileOutputStream.java:260) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) at mySession.writeCommand(mySession.java:169) 
+4
source share
2 answers

What happens is that the external process you are trying to record has closed the channel connected to its standard input streams. Maybe he just got out.

Try reading and printing the standard output of the processes and the standard error to see if they give an explanation as to what is happening.

+6
source

Well, this is the case when you closed the streams, and even after that you try to write data to the streams ...

I assume that one thread is processed in two threads, where one thread could close the thread (it could be software or some sort of exception in the last block of thread closure). and another stream is not notified and tries to write to this stream.

Hope this helps you.

+2
source

Source: https://habr.com/ru/post/1340138/


All Articles