-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
Tested in 1.5.0_02-b09
ADDITIONAL OS VERSION INFORMATION :
Appears to be a problem in Java library, so applicable to all OSs.
A DESCRIPTION OF THE PROBLEM :
FilterOutputStream silently ignores exceptions when doing a flush on close.
This can hide IO problems such a full disk. The particular case where it got
me was using a ZipOutputStream over a BufferedOutputStream.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.zip.*;
class test
{
static class LimitOutputStream extends OutputStream
{
public void write(int n) throws IOException
{
num++;
check();
}
public void write(byte[] buf) throws IOException
{
num += buf.length;
check();
}
public void write(byte[] buf, int off, int len) throws IOException
{
num += len;
check();
}
void check() throws IOException
{
if (num > 80)
{
//System.out.println("Limit.check: " + num);
//Thread.dumpStack();
throw new IOException("all full!");
}
}
int num;
}
public static void main(String[] args)
throws Exception
{
ZipOutputStream out =
new ZipOutputStream(
new BufferedOutputStream(
new LimitOutputStream()));
out.putNextEntry(new ZipEntry("entry"));
for(int i=0; i<10000; ++i)
out.write(new byte[100]);
out.closeEntry();
// out.flush(); without this line the close appears to silently work
out.close();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
You must explicitly flush() before close() if want to have an underlying
exception raised.
Release Regression From : 1.4.2_09
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
Tested in 1.5.0_02-b09
ADDITIONAL OS VERSION INFORMATION :
Appears to be a problem in Java library, so applicable to all OSs.
A DESCRIPTION OF THE PROBLEM :
FilterOutputStream silently ignores exceptions when doing a flush on close.
This can hide IO problems such a full disk. The particular case where it got
me was using a ZipOutputStream over a BufferedOutputStream.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.zip.*;
class test
{
static class LimitOutputStream extends OutputStream
{
public void write(int n) throws IOException
{
num++;
check();
}
public void write(byte[] buf) throws IOException
{
num += buf.length;
check();
}
public void write(byte[] buf, int off, int len) throws IOException
{
num += len;
check();
}
void check() throws IOException
{
if (num > 80)
{
//System.out.println("Limit.check: " + num);
//Thread.dumpStack();
throw new IOException("all full!");
}
}
int num;
}
public static void main(String[] args)
throws Exception
{
ZipOutputStream out =
new ZipOutputStream(
new BufferedOutputStream(
new LimitOutputStream()));
out.putNextEntry(new ZipEntry("entry"));
for(int i=0; i<10000; ++i)
out.write(new byte[100]);
out.closeEntry();
// out.flush(); without this line the close appears to silently work
out.close();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
You must explicitly flush() before close() if want to have an underlying
exception raised.
Release Regression From : 1.4.2_09
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
- relates to
-
JDK-6390383 (spec) FilterOutputStream.close() silently ignores flush() exceptions
-
- Closed
-
-
JDK-4953311 Buffer size in BufferedInputStream and BufferedOutputStream is too small
-
- Resolved
-