JDK-1267258 : java.io.PipedOutputStream.write(b) method works wrong with closed stream
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.0.2
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1996-09-10
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Relates :  
Description

Name: saf@russia			Date: 09/10/96


This bug was found by St.Petersburg Java SQE team (by Stanislav Avzan).

The java.io.PipedOutputStream.write(b) method does not work according
to the Java language specification.

The Java Language specification 
(Version 1.0 - August 1, 1996)
says the following (please see item 22.15.1):

"22.15.1 public abstract void write(int b) throws
IOException 

The general contract for write is that one byte is written to the output
stream. The byte to be written is the eight low-order bits of the argument
b. The 24 high-order bits of b are ignored. 

If the byte cannot be written for any reason, an IOException is thrown. In
particular, an IOException may be thrown if the output stream has been
closed (p. 22.15.5)."

So this method should  throw IOException
if the output stream has been closed.
But in fact it does not.
 
This bug affects also write(b,off,len) method.

Here is the minimized test demonstrating the bug:
    

----- test17.java ---------------------------------------
import java.io.*;

public class test17 {

   public static void main( String[] argv ) {
     PipedOutputStream os = new PipedOutputStream();
     PipedInputStream is = new PipedInputStream();
     try {
       os.connect(is);
       os.close();
     } catch(Throwable e) {
       System.out.println("Test failed: unexpected <"+e+"> thrown");
       System.exit(1); 
     } 
     try {
       os.write(10);
       System.out.println("Test failed: IOException expected"); 

     } catch(IOException e) {
       System.out.println("Test passed: IOException thrown"); 
     } catch(Throwable e) {
       System.out.println("Test failed: unexpected <"+e+"> thrown"); 
     } 
   }
}

----- The output of the test: -------------------------

$JAVA test17
Test failed: IOException expected

-------------------------------------------------------


Workaround:
None
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

EVALUATION Possibly a duplicate. Coding error. deepa.viswanathan@eng 1998-02-06
06-02-1998