Menu

#22 Unnecessary not null check in Appender.encode()

open
nobody
Bug (26)
5
2009-03-18
2009-03-18
Anonymous
No

simple-4.1.8

in org.simpleframework.transport.Appender

public String encode(String encoding) throws IOException {
ByteBuffer segment = buffer.duplicate();
//if(segment != null) {
segment.flip();
//}
return encode(encoding, segment);
}

The check on non-null segment is not mandatory.
Anyway encode(encoding, segment) will throw a NullPointerException if segment is null.

Charset.decode(ByteBuffer) throws a NullPointer exception if the ByteBuffer is null.

Discussion

  • Nobody/Anonymous

    Thanks, ill address this.

     
  • Alain Fagot Béarez

    the method ByteBuffer#duplicate() never returns null

     

Log in to post a comment.