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-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new 956e15b2b Add a null check for the class loader of OsgiUtils
956e15b2b is described below

commit 956e15b2bf5ee037d508e2599790259b24a8c283
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Dec 12 12:15:23 2023 -0500

    Add a null check for the class loader of OsgiUtils
---
 src/changes/changes.xml                                        | 1 +
 src/main/java/org/apache/commons/compress/utils/OsgiUtils.java | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 99587b82b..7e498e251 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -53,6 +53,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" issue="COMPRESS-632" dev="ggregory" due-to="Yakov 
Shafranovich, Gary Gregory">Improve CPIO exception detection and handling 
#441.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
SkipShieldingInputStream without replacement (no longer used).</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Reuse 
commons-codec, don't duplicate package-private class PureJavaCrc32C.</action>
+      <action type="fix" dev="ggregory" due-to="alumi, Gary Gregory">Add a 
null check for the class loader of OsgiUtils #451.</action>
       <!--  UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
commons-lang3 from 3.13.0 to 3.14.0.</action>
       <action type="update" dev="ggregory" due-to="Dependabot">Bump 
com.github.marschall:memoryfilesystem from 2.6.1 to 2.7.0 #444.</action>
diff --git a/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java 
b/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
index f057c702b..123f3806e 100644
--- a/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
+++ b/src/main/java/org/apache/commons/compress/utils/OsgiUtils.java
@@ -27,9 +27,8 @@ public class OsgiUtils {
     private static final boolean inOsgiEnvironment;
 
     static {
-        inOsgiEnvironment = OsgiUtils.class.getClassLoader() != null
-            ? isBundleReference(OsgiUtils.class.getClassLoader().getClass())
-            : false;
+        final ClassLoader classLoader = OsgiUtils.class.getClassLoader();
+        inOsgiEnvironment = classLoader != null ? 
isBundleReference(classLoader.getClass()) : false;
     }
 
     private static boolean isBundleReference(final Class<?> clazz) {

Reply via email to