Java

Java

Made by DeepSource

readLine() result is read without a null check JAVA-S0220

Bug risk
Critical

The result of invoking readLine() is read without checking to see if it is null.

String a = bufReader.readLine();
int b = a.length; // Will throw an NPE if a is null.

If there are no more lines of text to read, readLine() will return null and dereferencing that will generate a null pointer exception.

Unless you are absolutely confident that this will not happen (though it is a sensible thing to do even then), check if the result is null and perform an appropriate action if it is.