You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2022/01/13 16:13:23 UTC

[pdfbox-jbig2] branch master updated: PDFBOX-4671: add/rearrange classloader based on a proposal from Clifford Dann

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

lehmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pdfbox-jbig2.git


The following commit(s) were added to refs/heads/master by this push:
     new 8939743  PDFBOX-4671: add/rearrange classloader based on a proposal from Clifford Dann
8939743 is described below

commit 893974397f0abf94278d087136ff5d286f038e6b
Author: Andreas Lehmkühler <an...@lehmi.de>
AuthorDate: Thu Jan 13 17:13:10 2022 +0100

    PDFBOX-4671: add/rearrange classloader based on a proposal from Clifford
    Dann
---
 src/main/java/org/apache/pdfbox/jbig2/util/ServiceLookup.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/pdfbox/jbig2/util/ServiceLookup.java b/src/main/java/org/apache/pdfbox/jbig2/util/ServiceLookup.java
index 5a8b4f9..f5d3da1 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/util/ServiceLookup.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/util/ServiceLookup.java
@@ -33,15 +33,23 @@ public class ServiceLookup<B>
         Iterator<B> services = null;
         if (clsLoader != null)
         {
+            // use the provided class loader
             services = ServiceLoader.load(cls, clsLoader).iterator();
         }
         if (services == null || !services.hasNext())
         {
+            // use the context class loader of the current thread
+            services = ServiceLoader.load(cls, Thread.currentThread().getContextClassLoader()).iterator();
+        }
+        if (services == null || !services.hasNext())
+        {
+            // use the class loader which was used to load the provided class
             services = ServiceLoader.load(cls, cls.getClass().getClassLoader()).iterator();
         }
         if (services == null || !services.hasNext())
         {
-            services = ServiceLoader.load(cls).iterator();
+            // use the system class loader
+            services = ServiceLoader.load(cls, ClassLoader.getSystemClassLoader()).iterator();
         }
         return services;
     }