A DESCRIPTION OF THE PROBLEM :
The InputStreamReader constructors do not specify their decoding behavior (e.g. what happens when a decoding error occurs). They should do so, in terms of an equivalent CharsetDecoder. Note that in the "expected" documentation below, I made the simpler constructors refer to the more complex constructor. This avoids duplication, and as a bonus unambiguously specifies what "the default charset" and "the named charset" are.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public InputStreamReader(InputStream in)
Creates an InputStreamReader that is equivalent to: new InputStreamReader(in, Charset.defaultCharset())
public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException
Creates an InputStreamReader that is equivalent to: new InputStreamReader(in, Charset.forName(charsetName))
public InputStreamReader(InputStream in, Charset cs)
Creates an InputStreamReader that uses a charset decoder equivalent to:
cs.newDecoder().
onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
public InputStreamReader(InputStream in, CharsetDecoder dec)
Creates an InputStreamReader that uses the given charset decoder.
ACTUAL -
public InputStreamReader(InputStream in)
Creates an InputStreamReader that uses the default charset.
public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException
Creates an InputStreamReader that uses the named charset.
public InputStreamReader(InputStream in, Charset cs)
Creates an InputStreamReader that uses the given charset.
public InputStreamReader(InputStream in, CharsetDecoder dec)
Creates an InputStreamReader that uses the given charset decoder.
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/io/InputStreamReader.html
The InputStreamReader constructors do not specify their decoding behavior (e.g. what happens when a decoding error occurs). They should do so, in terms of an equivalent CharsetDecoder. Note that in the "expected" documentation below, I made the simpler constructors refer to the more complex constructor. This avoids duplication, and as a bonus unambiguously specifies what "the default charset" and "the named charset" are.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public InputStreamReader(InputStream in)
Creates an InputStreamReader that is equivalent to: new InputStreamReader(in, Charset.defaultCharset())
public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException
Creates an InputStreamReader that is equivalent to: new InputStreamReader(in, Charset.forName(charsetName))
public InputStreamReader(InputStream in, Charset cs)
Creates an InputStreamReader that uses a charset decoder equivalent to:
cs.newDecoder().
onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
public InputStreamReader(InputStream in, CharsetDecoder dec)
Creates an InputStreamReader that uses the given charset decoder.
ACTUAL -
public InputStreamReader(InputStream in)
Creates an InputStreamReader that uses the default charset.
public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException
Creates an InputStreamReader that uses the named charset.
public InputStreamReader(InputStream in, Charset cs)
Creates an InputStreamReader that uses the given charset.
public InputStreamReader(InputStream in, CharsetDecoder dec)
Creates an InputStreamReader that uses the given charset decoder.
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/java/io/InputStreamReader.html