You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2019/09/30 16:23:16 UTC

[cxf] branch 3.2.x-fixes updated (8b14596 -> 532804e)

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

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


    from 8b14596  Recording .gitmergeinfo Changes
     new 9ce79e9  CXF-8125: support for thread-safe application-defined StAX factories
     new 532804e  CXF-8127: LoggingFeature - Wrong address concatenation

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:
 .../org/apache/cxf/interceptor/StaxInInterceptor.java     | 11 ++++++++++-
 .../org/apache/cxf/interceptor/StaxOutInterceptor.java    | 12 +++++++++++-
 core/src/main/java/org/apache/cxf/message/Message.java    |  6 ++++++
 .../cxf/ext/logging/event/DefaultLogEventMapper.java      |  2 +-
 .../apache/cxf/ext/logging/DefaultLogEventMapperTest.java | 15 +++++++++++++++
 5 files changed, 43 insertions(+), 3 deletions(-)


[cxf] 01/02: CXF-8125: support for thread-safe application-defined StAX factories

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

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

commit 9ce79e9af3bddac7da8b0e02c8d4ce0d2ca282aa
Author: Barnabas Bodnar <ba...@ser.de>
AuthorDate: Sun Sep 29 00:31:38 2019 +0200

    CXF-8125: support for thread-safe application-defined StAX factories
    
    (cherry picked from commit e41775274815d4080166548172023aaabf72f8e3)
    (cherry picked from commit b6fd6f7d96ce178030b3537165c9b779ce2d927c)
---
 .../java/org/apache/cxf/interceptor/StaxInInterceptor.java   | 11 ++++++++++-
 .../java/org/apache/cxf/interceptor/StaxOutInterceptor.java  | 12 +++++++++++-
 core/src/main/java/org/apache/cxf/message/Message.java       |  6 ++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
index ca035ef..47a38a8 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
@@ -34,6 +34,7 @@ import javax.xml.stream.XMLStreamReader;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.HttpHeaderHelper;
@@ -127,12 +128,20 @@ public class StaxInInterceptor extends AbstractPhaseInterceptor<Message> {
                     xreader = StaxUtils.createXMLStreamReader(is, encoding);
                 }
             } else {
-                synchronized (factory) {
+                if (PropertyUtils.isTrue(message.getContextualProperty(Message.THREAD_SAFE_STAX_FACTORIES))) {
                     if (reader != null) {
                         xreader = factory.createXMLStreamReader(reader);
                     } else {
                         xreader = factory.createXMLStreamReader(is, encoding);
                     }
+                } else {
+                    synchronized (factory) {
+                        if (reader != null) {
+                            xreader = factory.createXMLStreamReader(reader);
+                        } else {
+                            xreader = factory.createXMLStreamReader(is, encoding);
+                        }
+                    }
                 }
             }
             xreader = StaxUtils.configureReader(xreader, message);
diff --git a/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
index af41e12..5f182b8 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
@@ -32,6 +32,7 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.io.AbstractWrappedOutputStream;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -84,13 +85,22 @@ public class StaxOutInterceptor extends AbstractPhaseInterceptor<Message> {
                     xwriter = StaxUtils.createXMLStreamWriter(writer);
                 }
             } else {
-                synchronized (factory) {
+                if (PropertyUtils.isTrue(message.getContextualProperty(Message.THREAD_SAFE_STAX_FACTORIES))) {
                     if (writer == null) {
                         os = setupOutputStream(os);
                         xwriter = factory.createXMLStreamWriter(os, encoding);
                     } else {
                         xwriter = factory.createXMLStreamWriter(writer);
                     }
+                } else {
+                    synchronized (factory) {
+                        if (writer == null) {
+                            os = setupOutputStream(os);
+                            xwriter = factory.createXMLStreamWriter(os, encoding);
+                        } else {
+                            xwriter = factory.createXMLStreamWriter(writer);
+                        }
+                    }
                 }
             }
             if (MessageUtils.getContextualBoolean(message, FORCE_START_DOCUMENT, false)) {
diff --git a/core/src/main/java/org/apache/cxf/message/Message.java b/core/src/main/java/org/apache/cxf/message/Message.java
index ed7be5b..aa4dbe3 100644
--- a/core/src/main/java/org/apache/cxf/message/Message.java
+++ b/core/src/main/java/org/apache/cxf/message/Message.java
@@ -183,6 +183,12 @@ public interface Message extends StringMap {
     String CONNECTION_TIMEOUT = "javax.xml.ws.client.connectionTimeout";
     String RECEIVE_TIMEOUT = "javax.xml.ws.client.receiveTimeout";
 
+    /**
+     * Boolean property to indicate whether application-defined StAX-factories (stored as contextual property in the
+     * message) are thread-safe. If set to {@code true}, CXF doesn't synchronize accesses to the factories.
+     */
+    String THREAD_SAFE_STAX_FACTORIES = Message.class.getName() + ".THREAD_SAFE_STAX_FACTORIES";
+
     String getId();
     void setId(String id);
 


[cxf] 02/02: CXF-8127: LoggingFeature - Wrong address concatenation

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

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

commit 532804e8230daf4920286d9c9f73067979719398
Author: kkrisz1 <kr...@gmail.com>
AuthorDate: Mon Sep 30 15:24:06 2019 +0200

    CXF-8127: LoggingFeature - Wrong address concatenation
    
    (cherry picked from commit 8808d26b0c95cea8de694087b06bbd131ac12d17)
    (cherry picked from commit fcd4d7aedf4e7c5d500300dba9d3a1735b506e9c)
---
 .../cxf/ext/logging/event/DefaultLogEventMapper.java      |  2 +-
 .../apache/cxf/ext/logging/DefaultLogEventMapperTest.java | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
index 00ea2ec..755a4d3 100644
--- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
+++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
@@ -154,7 +154,7 @@ public class DefaultLogEventMapper {
             if (uri != null && uri.startsWith("/")) {
                 if (address != null && !address.startsWith(uri)) {
                     if (address.endsWith("/") && address.length() > 1) {
-                        address = address.substring(0, address.length());
+                        address = address.substring(0, address.length() - 1);
                     }
                     uri = address + uri;
                 }
diff --git a/rt/features/logging/src/test/java/org/apache/cxf/ext/logging/DefaultLogEventMapperTest.java b/rt/features/logging/src/test/java/org/apache/cxf/ext/logging/DefaultLogEventMapperTest.java
index 229c9f7..a7b78e7 100644
--- a/rt/features/logging/src/test/java/org/apache/cxf/ext/logging/DefaultLogEventMapperTest.java
+++ b/rt/features/logging/src/test/java/org/apache/cxf/ext/logging/DefaultLogEventMapperTest.java
@@ -57,5 +57,20 @@ public class DefaultLogEventMapperTest {
         Assert.assertEquals("", event.getOperationName());
     }
 
+    /**
+     * Test for address concatenation in CXF-8127
+     */
+    @Test
+    public void testUriValue() {
+        DefaultLogEventMapper mapper = new DefaultLogEventMapper();
+        Message message = new MessageImpl();
+        message.put(Message.ENDPOINT_ADDRESS, "http://localhost:9001/");
+        message.put(Message.REQUEST_URI, "/api");
+        Exchange exchange = new ExchangeImpl();
+        message.setExchange(exchange);
+        LogEvent event = mapper.map(message);
+        Assert.assertEquals("http://localhost:9001/api", event.getAddress());
+    }
+
 
 }