-
Bug
-
Resolution: Fixed
-
P3
-
1.1.3
-
1.1.6
-
x86
-
windows_95
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2017377 | 1.2.0 | Joe Fialli | P3 | Resolved | Fixed | 1.2beta3 |
Unhandled
Name: rm29839 Date: 10/13/97
pataxo{mdias}1: cat bugfound.txt
Subject: JDK1.1.3-Win95 Bug found: ObjectStream and Process
Hi,
Before sending you this mail, I looked for any register about this kind of bug.
The problem is on inter-process communication with ObjectStream. The Master process
starts the slave and try to send an Object to this slave by its outputStream.
The code is presented below, with the output of both processes...
I tried many different little changes to code, but none worked.
This problem doesn't occur with BufferedReader and PrintWriter.
I'm quite sure it is a bug. But if it isn't (if there is any mistake in the code),
I'd like to know how could I do to make this interprocess communication without
using Sockets. (Surprising, I tried once to create object streams to communicate master
an slave processes with socket and it didn't work either ?! But with independent processes,
it worked very fine. =:-0
(I'm using Win95, and I tried this code with jdk1.1.3 and jdk1.1.1)
Thanks a lot for your attention.
Marcio Dias
/* ***********************************************************************************
* Output
*************************************************************************************/
D:\COPSE\temp>java Master
[DEBUG] Creating ObjectOutputStream...
%S% [SlaveErrorStreamHandler running...]
[DEBUG] Writing to ObjectOutputStream...
[DEBUG] Waiting for Slave...
%S% [DEBUG] Creating ObjectInputStream...
%S% [DEBUG] Reading from ObjectInputStream...
%S% java.io.IOException
%S% at java.io.BufferedInputStream.available(BufferedInputStream.java:268)
%S% at java.io.ObjectInputStream.available(ObjectInputStream.java:1281)
%S% at java.io.ObjectInputStream.readObject(ObjectInputStream.java:211)
%S% at Slave.<init>(Slave.java:15)
%S% at Slave.main(Slave.java:5)
/* ***********************************************************************************
* Master Application
*************************************************************************************/
import java.io.*;
public class Master
{
public static void main(String[] args) { new Master(); }
public Master()
{
_SlaveErrorStreamHandler handler;
try {
Process slave = Runtime.getRuntime().exec( "java Slave" );
handler = new _SlaveErrorStreamHandler( slave.getErrorStream() );
handler.start();
System.err.println( "[DEBUG] Creating ObjectOutputStream..." );
OutputStream out = slave.getOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream( out );
System.err.println( "[DEBUG] Writing to ObjectOutputStream..." );
objOut.writeObject( new String( "Master to slave: 1") );
objOut.writeObject( new String( "Master to slave: 2") );
objOut.flush();
System.err.println( "[DEBUG] Waiting for Slave..." );
slave.waitFor();
handler.stop();
} catch (Exception e)
{
e.printStackTrace( System.out );
}
}
}
class _SlaveErrorStreamHandler
extends Thread
{
BufferedReader pErrorReader;
public _SlaveErrorStreamHandler ( InputStream errorStream )
{
pErrorReader = new BufferedReader( new InputStreamReader(errorStream) );
}
public void run()
{
System.err.println( "%S% [SlaveErrorStreamHandler running...]" );
while( true )
{
try{
String msg = pErrorReader.readLine();
if( msg != null )
System.err.println( "%S% " + msg );
} catch( IOException e ){}
}
}
}
/* ***********************************************************************************/
/* ***********************************************************************************
* Slave Application
*************************************************************************************/
import java.io.*;
public class Slave
{
public static void main(String[] args) { new Slave(); }
public Slave()
{
try
{
System.err.println( "[DEBUG] Creating ObjectInputStream..." );
ObjectInputStream objIn = new ObjectInputStream( System.in );
System.err.println( "[DEBUG] Reading from ObjectInputStream..." );
System.err.println( (String)objIn.readObject() );
System.err.println( (String)objIn.readObject() );
System.err.flush();
} catch (Exception e)
{
e.printStackTrace( System.err );
System.err.flush();
}
}
}
/* ***********************************************************************************/
company - Federal University of Rio de Janeiro , email - ###@###.###
======================================================================
Name: rm29839 Date: 10/13/97
pataxo{mdias}1: cat bugfound.txt
Subject: JDK1.1.3-Win95 Bug found: ObjectStream and Process
Hi,
Before sending you this mail, I looked for any register about this kind of bug.
The problem is on inter-process communication with ObjectStream. The Master process
starts the slave and try to send an Object to this slave by its outputStream.
The code is presented below, with the output of both processes...
I tried many different little changes to code, but none worked.
This problem doesn't occur with BufferedReader and PrintWriter.
I'm quite sure it is a bug. But if it isn't (if there is any mistake in the code),
I'd like to know how could I do to make this interprocess communication without
using Sockets. (Surprising, I tried once to create object streams to communicate master
an slave processes with socket and it didn't work either ?! But with independent processes,
it worked very fine. =:-0
(I'm using Win95, and I tried this code with jdk1.1.3 and jdk1.1.1)
Thanks a lot for your attention.
Marcio Dias
/* ***********************************************************************************
* Output
*************************************************************************************/
D:\COPSE\temp>java Master
[DEBUG] Creating ObjectOutputStream...
%S% [SlaveErrorStreamHandler running...]
[DEBUG] Writing to ObjectOutputStream...
[DEBUG] Waiting for Slave...
%S% [DEBUG] Creating ObjectInputStream...
%S% [DEBUG] Reading from ObjectInputStream...
%S% java.io.IOException
%S% at java.io.BufferedInputStream.available(BufferedInputStream.java:268)
%S% at java.io.ObjectInputStream.available(ObjectInputStream.java:1281)
%S% at java.io.ObjectInputStream.readObject(ObjectInputStream.java:211)
%S% at Slave.<init>(Slave.java:15)
%S% at Slave.main(Slave.java:5)
/* ***********************************************************************************
* Master Application
*************************************************************************************/
import java.io.*;
public class Master
{
public static void main(String[] args) { new Master(); }
public Master()
{
_SlaveErrorStreamHandler handler;
try {
Process slave = Runtime.getRuntime().exec( "java Slave" );
handler = new _SlaveErrorStreamHandler( slave.getErrorStream() );
handler.start();
System.err.println( "[DEBUG] Creating ObjectOutputStream..." );
OutputStream out = slave.getOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream( out );
System.err.println( "[DEBUG] Writing to ObjectOutputStream..." );
objOut.writeObject( new String( "Master to slave: 1") );
objOut.writeObject( new String( "Master to slave: 2") );
objOut.flush();
System.err.println( "[DEBUG] Waiting for Slave..." );
slave.waitFor();
handler.stop();
} catch (Exception e)
{
e.printStackTrace( System.out );
}
}
}
class _SlaveErrorStreamHandler
extends Thread
{
BufferedReader pErrorReader;
public _SlaveErrorStreamHandler ( InputStream errorStream )
{
pErrorReader = new BufferedReader( new InputStreamReader(errorStream) );
}
public void run()
{
System.err.println( "%S% [SlaveErrorStreamHandler running...]" );
while( true )
{
try{
String msg = pErrorReader.readLine();
if( msg != null )
System.err.println( "%S% " + msg );
} catch( IOException e ){}
}
}
}
/* ***********************************************************************************/
/* ***********************************************************************************
* Slave Application
*************************************************************************************/
import java.io.*;
public class Slave
{
public static void main(String[] args) { new Slave(); }
public Slave()
{
try
{
System.err.println( "[DEBUG] Creating ObjectInputStream..." );
ObjectInputStream objIn = new ObjectInputStream( System.in );
System.err.println( "[DEBUG] Reading from ObjectInputStream..." );
System.err.println( (String)objIn.readObject() );
System.err.println( (String)objIn.readObject() );
System.err.flush();
} catch (Exception e)
{
e.printStackTrace( System.err );
System.err.flush();
}
}
}
/* ***********************************************************************************/
company - Federal University of Rio de Janeiro , email - ###@###.###
======================================================================
- backported by
-
JDK-2017377 readObject() does not handle IOException thrown by InputStream.available()
- Resolved
- relates to
-
JDK-4156692 jdk117d - regression test failure: io\Serializable\
- Resolved