Skip to content

Commit f6625e8

Browse files
committed
Fix NPE when reader reads null line.
Old code called trim() on ``line``, and tested for ``line == null`` afterwards. If ``line`` is actually ``null`` this will cause an ``NullPointerException``
1 parent d19ff0d commit f6625e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/org/scijava/plugins/scripting/java/JavaEngine.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,9 @@ private static String getFullClassName(final File file) throws IOException {
550550
Pattern.compile(".*public class ([a-zA-Z0-9_]*).*");
551551
final BufferedReader reader = new BufferedReader(new FileReader(file));
552552
for (;;) {
553-
String line = reader.readLine().trim();
553+
String line = reader.readLine();
554554
if (line == null) break;
555+
line = line.trim();
555556
outerLoop:
556557
while (line.startsWith("/*")) {
557558
int end = line.indexOf("*/", 2);

0 commit comments

Comments
 (0)