You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2022/08/13 22:53:21 UTC

[cxf] branch 3.4.x-fixes updated (730df57e78 -> bd7b884ca0)

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

reta pushed a change to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


    from 730df57e78 Update Dropwizard Metrics to 4.1.33
     new 7d92c2549b CXF-8732: [regression] activation DataSource requires to run JAXRS
     new bd7b884ca0 Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |  2 ++
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     | 39 ++++++++++++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)


[cxf] 01/02: CXF-8732: [regression] activation DataSource requires to run JAXRS

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 7d92c2549bd03a0f4fbf2bd71b733b8a1325036a
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Aug 13 18:28:29 2022 -0400

    CXF-8732: [regression] activation DataSource requires to run JAXRS
    
    (cherry picked from commit 41a7c8b358aab1ad219a4b7924411cbcfc9edd06)
---
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     | 39 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index acce61611d..41c6680d7c 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -39,6 +39,7 @@ import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.SortedMap;
@@ -48,7 +49,6 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.stream.Collectors;
 
-import javax.activation.DataSource;
 import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.HttpMethod;
@@ -85,6 +85,7 @@ import javax.ws.rs.ext.WriterInterceptorContext;
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
@@ -202,6 +203,40 @@ public final class JAXRSUtils {
             "java.util.concurrent.CompletableFuture",
             "java.util.concurrent.CompletionStage"
         ));
+    private static final LazyLoadedClass DATA_SOURCE_CLASS = new LazyLoadedClass("javax.activation.DataSource");
+
+    // Class to lazily call the ClassLoaderUtil.loadClass, but do it once
+    // and cache the result.  Then use the class to create instances as needed.
+    // This avoids calling loadClass every time as calling loadClass is super expensive, 
+    // particularly if the class cannot be found and particularly in OSGi where the 
+    // search is very complex. This would record that the class is not found and prevent 
+    // future searches.
+    private static class LazyLoadedClass {
+        private final String className;
+        private volatile boolean initialized;
+        private Class<?> cls;
+
+        LazyLoadedClass(String cn) {
+            className = cn;
+        }
+
+        synchronized Optional<Class<?>> load() {
+            if (!initialized) {
+                try {
+                    cls = ClassLoaderUtils.loadClass(className, ProviderFactory.class);
+                } catch (final Throwable ex) {
+                    LOG.fine(className + " not available, skipping");
+                }
+                initialized = true;
+            }
+
+            return Optional.ofNullable(cls);
+        }
+
+        boolean isAssignableFrom(Class<?> another) {
+            return load().map(c -> c.isAssignableFrom(another)).orElse(false);
+        }
+    }
 
     private JAXRSUtils() {
     }
@@ -242,7 +277,7 @@ public final class JAXRSUtils {
         return STREAMING_OUT_TYPES.contains(type) 
             || Closeable.class.isAssignableFrom(type)
             || Source.class.isAssignableFrom(type)
-            || DataSource.class.isAssignableFrom(type);
+            || DATA_SOURCE_CLASS.isAssignableFrom(type);
     }
 
     public static List<PathSegment> getPathSegments(String thePath, boolean decode) {


[cxf] 02/02: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit bd7b884ca0b7c6e286300fdbd3bc25e6a86ee35c
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Aug 13 18:40:10 2022 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 312773f566..a4559e40bb 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -28,6 +28,7 @@ B 1cc69bd3ae56bcb514d706d876f9b97135253d34
 B 24cdfa9312f878a14ad1ac19b4c9750ae3d8e60e
 B 25ba7358dd56f2827bc2f48098d4e315e6f1baea
 B 2634ed5bcfb6001c1a72788a1152bedc6315585e
+B 26416c68a98a37b88ab29cb434eb3bd79b0b128b
 B 269c7c8fe4553c5307fd938dbba51af5a1535482
 B 27d9f6ac75162f9bbcfcf2bb2f5b569baf424a5d
 B 28780a99ff888d6e27c1c6d92dda0046bf513d33
@@ -270,6 +271,7 @@ M 5409cc649fa5542e0f68af24546ab05a4e38a50c
 M 541ec1e3bd63890a64831d2470f972bf0ed4811d
 M 54538c21fac194884dad69d6543e67a9c8865bab
 M 54c6601328dc47713ae8bcb3149d4ae7e2f8efb2
+M 55f97faa84c7c1dfa5d769c2cf08bc3460c46018
 M 56e2ebb60cf8b581da41fbb22b57266ef5574344
 M 59ef61b0288e1e9b05f0bdc3e78f8b55eb76ad88
 M 59f2f96920558470d08483e924a9b088a85beaad