This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 905f4f91e4d0b5c4d145729f16bad90b1847f0be Author: Andriy Redko <[email protected]> AuthorDate: Thu Jun 2 21:53:51 2022 -0400 CXF-8478: fixing jaxrs.ee.rs.container.requestcontext setRequestUriTwoUrisTest --- .../org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java | 7 ++++++- .../src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java | 2 ++ .../org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java index a13f6ee1ea..4222cbacf2 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java @@ -28,6 +28,7 @@ import javax.ws.rs.core.Request; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.io.DelegatingInputStream; import org.apache.cxf.jaxrs.utils.ExceptionUtils; @@ -108,7 +109,11 @@ public class ContainerRequestContextImpl extends AbstractRequestContextImpl String baseUriString = new UriInfoImpl(m).getBaseUri().toString(); String requestUriString = requestUri.toString(); if (!requestUriString.startsWith(baseUriString)) { - setRequestUri(requestUri, URI.create("/")); + String path = requestUri.getRawPath(); + if (StringUtils.isEmpty(path)) { + path = "/"; + } + setRequestUri(requestUri.resolve("/"), URI.create(path)); return; } requestUriString = requestUriString.substring(baseUriString.length()); diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java index 9071b28ab4..4eb9a96667 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java @@ -147,6 +147,8 @@ public class BookServer20 extends AbstractServerTestServerBase { if ("wrongpath".equals(path)) { context.setRequestUri(URI.create("/bookstore/bookheaders/simple")); + } else if ("absolutepath".equals(path)) { + context.setRequestUri(URI.create("http://localhost:888/bookstore/bookheaders/simple")); } else if ("throwException".equals(path)) { context.setProperty("filterexception", "prematch"); throw new InternalServerErrorException( diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java index 0f0f5e2b67..7d9dae6af6 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java @@ -355,6 +355,12 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase String address = "http://localhost:" + PORT + "/wrongpath"; doTestGetBookAsync(address, false); } + + @Test + public void testGetBookAbsolutePathAsync() throws Exception { + String address = "http://localhost:" + PORT + "/absolutepath"; + doTestGetBookAsync(address, false); + } @Test public void testPostCollectionGenericEntity() throws Exception {
