Skip to content

Instantly share code, notes, and snippets.

@MetalBeetle
Created March 24, 2011 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MetalBeetle/885338 to your computer and use it in GitHub Desktop.
Save MetalBeetle/885338 to your computer and use it in GitHub Desktop.
BufferedOutputStream Considered Harmful
package bufferedoutputstreamtest;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Contrary to what you'd expect, this runs with no exception thrown.
* Thanks, BufferedOutputStream!
*/
public class Main {
public static void main(String[] args) throws IOException {
OutputStream crashy = new OutputStream() {
@Override
public void write(int i) throws IOException {
throw new IOException("crash");
}
};
BufferedOutputStream bos = new BufferedOutputStream(crashy);
bos.write(33);
bos.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment