You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/16 14:01:07 UTC

[commons-bcel] branch master updated: Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


The following commit(s) were added to refs/heads/master by this push:
     new 3703a2d1 Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String)
3703a2d1 is described below

commit 3703a2d11b29fef59e8e112cc376157e842c0a22
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Wed Nov 16 09:01:03 2022 -0500

    Avoid internal NPE in
    org.apache.bcel.util.ClassPath.getInputStream(String, String)
---
 src/changes/changes.xml                           | 1 +
 src/main/java/org/apache/bcel/util/ClassPath.java | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 966f0887..c8e0a127 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -82,6 +82,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.SourceFile constructors now throw ClassFormatException on invalid input.</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.ALOAD_0 value is wrong (regression from 6.6.0).</action>
       <action                  type="fix" dev="ggregory" due-to="Gary Gregory">InstructionConstants.DCONST_0 value is wrong (regression from 6.6.0).</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">Avoid internal NPE in org.apache.bcel.util.ClassPath.getInputStream(String, String).</action>
       <!-- UPDATE -->
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Bump spotbugs-maven-plugin from 4.7.2.2 to 4.7.3.0 #167.</action>
     </release>
diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java
index 6436b5ca..0cb45757 100644
--- a/src/main/java/org/apache/bcel/util/ClassPath.java
+++ b/src/main/java/org/apache/bcel/util/ClassPath.java
@@ -692,7 +692,8 @@ public class ClassPath implements Closeable {
     public InputStream getInputStream(final String name, final String suffix) throws IOException {
         InputStream inputStream = null;
         try {
-            inputStream = getClass().getClassLoader().getResourceAsStream(name + suffix); // may return null
+            final java.lang.ClassLoader classLoader = getClass().getClassLoader();
+            inputStream = classLoader == null ? null : classLoader.getResourceAsStream(name + suffix); // may return null
         } catch (final Exception ignored) {
             // ignored
         }