27 November 2018

CEStreamExhausted anti-pattern

This exception is thrown when EOF is found. Literally is an anti-pattern (like a goto)

https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/sun/misc/CEStreamExhausted.java

/** This exception is thrown when EOF is reached */
public class CEStreamExhausted extends IOException { };


Which is executed at line 117 de BASE64Decoder :

https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/sun/misc/BASE64Decoder.java

do {
   i = inStream.read();
   if (i == -1) {
      throw new CEStreamExhausted();
   }
} while (i == '\n' || i == '\r');


Therefore it's a false-positive if any APM raise it.

--------------------------------------------------------------------------------

Me faltó agregar que la clase que llama a la lanza la excepcion en cuestion es: CharacterDecoder.java

Y lo que hace es tener un loop infinito while(true) que se sale de ahi al atrapar dicha exception.

Por lo tanto queda demostrado que es un falso-positivo.

while (true) {

int length;


try {

length = decodeLinePrefix(ps, bStream);

for (i = 0; (i+bytesPerAtom()) < length; i += bytesPerAtom()) {

decodeAtom(ps, bStream, bytesPerAtom());

totalBytes += bytesPerAtom();

}

if ((i + bytesPerAtom()) == length) {

decodeAtom(ps, bStream, bytesPerAtom());

totalBytes += bytesPerAtom();

} else {

decodeAtom(ps, bStream, length - i);

totalBytes += (length - i);

}

decodeLineSuffix(ps, bStream);

} catch (CEStreamExhausted e) {

break;

}


No comments :

My Blog List

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.