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 15:31:50 UTC

[cxf] branch master updated: CXF-8127: LoggingFeature - Wrong address concatenation

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

ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 8808d26  CXF-8127: LoggingFeature - Wrong address concatenation
     new b699913  Merge pull request #583 from kkrisz1/CXF-8127
8808d26 is described below

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

    CXF-8127: LoggingFeature - Wrong address concatenation
---
 .../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 107b240..dd3bcdb 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
@@ -163,7 +163,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());
+    }
+
 
 }