FilterOutputStream the most useless class in the JDK?

I fell into the exact same trap as Riven did url=http://www.java-gaming.org/index.php/topic,22574.0[/url].

What is the point of this class existing if the default method implementations are so stupid :confused:

FilterInputStream is similarly flawed in that read(byte[]) invokes read(byte[],offset,len), resulting in it invoking your subclass implementation potentially causing unintended behaviour.
There’s a hint in the javadoc that this flawed behaviour is to compensate for a stupid implementation in FilterInputStream’s known subclasses:

These Filter classes should be such trivial wrapper implementations it boggles my mind how they ended up having such convoluted & downright broken behaviour.

They should both be deprecated, and flagged with a big ā€œDO NOT USE THESE CLASSES, THEY’RE FUNCTIONALLY USELESS/BROKENā€ warning.

Welcome to the club! A lot of I/O code is seriously broken in the JRE. They never bothered to fix NIO Selectors (accept() rapidly firing, returning zero), every serious networking library has worked around it (often poorly) as can’t rely on its skillfully documented blocking behavior.

It seems the core developers were mere human, but sometimes you wonder how we can trust this crapfest in our industries.

Did you know that the SOCKS4 proxy in java.lang.Socket implementation forcefully closes the connection if receiving the SOCKS4 header takes more than 4 reads in the OS file handle? As for why? Nobody knows. They just wrote a for loop with an i<4 condition.

Gosh! But there are so many to choose from? I can’t decide!