[jira] [Commented] (CXF-7676) TCK: An Entity OutputStream is not set before ClientRequestFilterInterceptor.handleMessage() processes a user's ClientRequestFilter which modifies the EntityStream via C
[ https://issues.apache.org/jira/browse/CXF-7676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16402560#comment-16402560 ] Adam Anderson commented on CXF-7676: Can we backport this to 3.1.X? > TCK: An Entity OutputStream is not set before > ClientRequestFilterInterceptor.handleMessage() processes a user's > ClientRequestFilter which modifies the EntityStream via > ClientRequestContext.setEntityStream() > --- > > Key: CXF-7676 > URL: https://issues.apache.org/jira/browse/CXF-7676 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Environment: all versions, any environment >Reporter: Adam Anderson >Assignee: Daniel Kulp >Priority: Major > Fix For: 3.2.3 > > Original Estimate: 1h > Remaining Estimate: 1h > > CXF is failing a test in both the JAXRS 2.0 and 2.1 TCKs where a user creates > a ClientRequestFilter which wraps the EntityStream in the filter() method via > ClientRequestContext.setEntityStream(). > CXF uses Phases to order the interceptors in the PhaseInterceptorChain. > [http://cxf.apache.org/docs/interceptors.html] > A customer's client filter code gets executed in > ClientRequestFilterInterceptor.handleMessage() during the PRE_LOGICAL phase > of the outgoing chain. > We don't actually create the entity output stream until HTTPConduit.prepare() > which is called by MessageSenderInterceptor.handleMessage() during the > PREPARE_SEND phase of the outgoing chain. > As a result, any interaction/modification of the entity stream by the user > gets overwritten. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7670) synthetic methods: equal candidates for handling the current request
[ https://issues.apache.org/jira/browse/CXF-7670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16402315#comment-16402315 ] ASF GitHub Bot commented on CXF-7670: - andymc12 closed pull request #388: [CXF-7670] create a single ClassResourceInfo per class + annotated method URL: https://github.com/apache/cxf/pull/388 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java index a8da8197fdb..5b793673799 100644 --- a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java +++ b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java @@ -99,6 +99,7 @@ private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationEx DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); f.setNamespaceAware(true); f.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); + f.setFeature("http://apache.org/xml/features/disallow-doctype-decl;, true); return f.newDocumentBuilder(); } DocumentBuilder factory = DOCUMENT_BUILDERS.get(loader); @@ -106,6 +107,7 @@ private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationEx DocumentBuilderFactory f2 = DocumentBuilderFactory.newInstance(); f2.setNamespaceAware(true); f2.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); + f2.setFeature("http://apache.org/xml/features/disallow-doctype-decl;, true); factory = f2.newDocumentBuilder(); DOCUMENT_BUILDERS.put(loader, factory); } diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java index f9d1ff51819..a9de4123ac7 100644 --- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java +++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java @@ -115,6 +115,11 @@ static { AEGIS_DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance(); AEGIS_DOCUMENT_BUILDER_FACTORY.setNamespaceAware(true); +try { + AEGIS_DOCUMENT_BUILDER_FACTORY.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); +} catch (javax.xml.parsers.ParserConfigurationException ex) { +// ignore +} String path = "/META-INF/cxf/aegis.xsd"; InputStream is = XMLTypeCreator.class.getResourceAsStream(path); diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java index 8f4316c489e..0f044e85d3b 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java @@ -311,44 +311,55 @@ private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableS MethodDispatcher md = new MethodDispatcher(); Class serviceClass = cri.getServiceClass(); +final Set annotatedMethods = new HashSet<>(); + for (Method m : serviceClass.getMethods()) { Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(serviceClass, m); -String httpMethod = AnnotationUtils.getHttpMethodValue(annotatedMethod); -Path path = AnnotationUtils.getMethodAnnotation(annotatedMethod, Path.class); +if (!annotatedMethods.contains(annotatedMethod)) { +evaluateResourceMethod(cri, enableStatic, md, m, annotatedMethod); +annotatedMethods.add(annotatedMethod); +} -if (httpMethod != null || path != null) { -if (!checkAsyncResponse(annotatedMethod)) { -continue; -} +} +cri.setMethodDispatcher(md); +} + +private static void evaluateResourceMethod(ClassResourceInfo cri, boolean enableStatic, MethodDispatcher md, + Method m, Method annotatedMethod) { +String httpMethod = AnnotationUtils.getHttpMethodValue(annotatedMethod); +Path path = AnnotationUtils.getMethodAnnotation(annotatedMethod, Path.class); + +if (httpMethod != null || path != null) { +if (!checkAsyncResponse(annotatedMethod)) { +return; +} -md.bind(createOperationInfo(m, annotatedMethod, cri, path, httpMethod), m); -if (httpMethod == null) {
[jira] [Resolved] (CXF-7676) TCK: An Entity OutputStream is not set before ClientRequestFilterInterceptor.handleMessage() processes a user's ClientRequestFilter which modifies the EntityStream via Cl
[ https://issues.apache.org/jira/browse/CXF-7676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Kulp resolved CXF-7676. -- Resolution: Fixed Assignee: Daniel Kulp > TCK: An Entity OutputStream is not set before > ClientRequestFilterInterceptor.handleMessage() processes a user's > ClientRequestFilter which modifies the EntityStream via > ClientRequestContext.setEntityStream() > --- > > Key: CXF-7676 > URL: https://issues.apache.org/jira/browse/CXF-7676 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Environment: all versions, any environment >Reporter: Adam Anderson >Assignee: Daniel Kulp >Priority: Major > Fix For: 3.2.3 > > Original Estimate: 1h > Remaining Estimate: 1h > > CXF is failing a test in both the JAXRS 2.0 and 2.1 TCKs where a user creates > a ClientRequestFilter which wraps the EntityStream in the filter() method via > ClientRequestContext.setEntityStream(). > CXF uses Phases to order the interceptors in the PhaseInterceptorChain. > [http://cxf.apache.org/docs/interceptors.html] > A customer's client filter code gets executed in > ClientRequestFilterInterceptor.handleMessage() during the PRE_LOGICAL phase > of the outgoing chain. > We don't actually create the entity output stream until HTTPConduit.prepare() > which is called by MessageSenderInterceptor.handleMessage() during the > PREPARE_SEND phase of the outgoing chain. > As a result, any interaction/modification of the entity stream by the user > gets overwritten. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7676) TCK: An Entity OutputStream is not set before ClientRequestFilterInterceptor.handleMessage() processes a user's ClientRequestFilter which modifies the EntityStream via C
[ https://issues.apache.org/jira/browse/CXF-7676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16402284#comment-16402284 ] ASF GitHub Bot commented on CXF-7676: - dkulp closed pull request #390: [CXF-7676] Create a proxy OutputStream to create an EntityStream that… URL: https://github.com/apache/cxf/pull/390 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java index 44430f393ca..d207d76ef87 100644 --- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java +++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java @@ -19,6 +19,7 @@ package org.apache.cxf.jaxrs.client.spec; import java.io.IOException; +import java.io.OutputStream; import java.util.List; import java.util.Map; @@ -39,6 +40,7 @@ import org.apache.cxf.message.MessageImpl; import org.apache.cxf.phase.Phase; import org.apache.cxf.transport.MessageObserver; +import org.apache.cxf.transport.http.ProxyOutputStream; public class ClientRequestFilterInterceptor extends AbstractOutDatabindingInterceptor { @@ -52,6 +54,12 @@ public void handleMessage(Message outMessage) throws Fault { return; } +// create an empty proxy output stream that the filter can interact with +// and save a reference for later +ProxyOutputStream pos = new ProxyOutputStream(); +outMessage.setContent(OutputStream.class, pos); +outMessage.setContent(ProxyOutputStream.class, pos); + Listfilters = pf.getClientRequestFilters(); if (!filters.isEmpty()) { diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java index 4b84aa32212..fda7b8fad29 100644 --- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java +++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java @@ -562,11 +562,21 @@ public void prepare(Message message) throws IOException { setHeadersByAuthorizationPolicy(message, currentAddress.getURI()); new Headers(message).setFromClientPolicy(getClient(message)); -message.setContent(OutputStream.class, - createOutputStream(message, - needToCacheRequest, - isChunking, - chunkThreshold)); + +// set the OutputStream on the ProxyOutputStream +ProxyOutputStream pos = message.getContent(ProxyOutputStream.class); +if (pos != null && message.getContent(OutputStream.class) != null) { +pos.setWrappedOutputStream(createOutputStream(message, + needToCacheRequest, + isChunking, + chunkThreshold)); +} else { +message.setContent(OutputStream.class, + createOutputStream(message, + needToCacheRequest, + isChunking, + chunkThreshold)); +} // We are now "ready" to "send" the message. } diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ProxyOutputStream.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ProxyOutputStream.java new file mode 100644 index 000..f1d0f4af1f8 --- /dev/null +++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ProxyOutputStream.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either
[jira] [Updated] (CXF-7679) PhaseManager is not loaded in bus Extension
[ https://issues.apache.org/jira/browse/CXF-7679?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Kulp updated CXF-7679: - Fix Version/s: (was: 3.2.3) > PhaseManager is not loaded in bus Extension > --- > > Key: CXF-7679 > URL: https://issues.apache.org/jira/browse/CXF-7679 > Project: CXF > Issue Type: Bug > Components: Bus >Affects Versions: 3.2.2 >Reporter: satishbt >Priority: Major > Labels: maven > > I am using below packages > > > org.apache.cxf > cxf-rt-rs-client > ${cxf.rs.version} > > > org.apache.cxf > cxf-rt-frontend-jaxrs > ${cxf.rs.version} > > > and > maven-shade-plugin > 2.4.3 > to package the my module jar . > doing a simple rest call. > return (DeviceTerminal) webClient.path("device").query("tac", > tacInfo) > .get(DeviceTerminal.class); > }); > > Problem i am seeing is when i run the jar and make rest call getting a > nullpointer exception due to phasemanager.class is not there in the extension > but i could see that bus-extensions.txt has the entry. > I could run the test case from intellij ide but when run the application from > command line. I am getting the below error. > 593 [vert.x-eventloop-thread-0] DEBUG com.telus.handler.RestHttpErrorHandler > - Handling REST API error ' (ContextMap={}) > java.lang.NullPointerException: null > at > org.apache.cxf.jaxrs.client.AbstractClient.setupOutInterceptorChain(AbstractClient.java:941) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > org.apache.cxf.jaxrs.client.AbstractClient.createMessage(AbstractClient.java:1013) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > org.apache.cxf.jaxrs.client.WebClient.finalizeMessage(WebClient.java:1075) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1048) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:897) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:866) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:431) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:611) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > com.telus.simota.client.ris.RISClientService.lambda$getDeviceTerminalForaGivenTac$0(RISClientService.java:23) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > com.telus.simota.client.APIClientComponent.sendRequest(APIClientComponent.java:32) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > com.telus.simota.client.ris.RISClientService.getDeviceTerminalForaGivenTac(RISClientService.java:20) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > com.telus.simota.add.handler.DeviceSwapEventHandler.handle(DeviceSwapEventHandler.java:41) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:219) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:120) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:120) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > com.telus.simota.transform.NotificationRequest.handle(NotificationRequest.java:48) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:219) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:120) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:120) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > com.telus.handler.validators.XMLContentValidator.validateContent(XMLContentValidator.java:76) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:219) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:120) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:120) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:82) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at > io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:42) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:219) > ~[MS-APIGateway-1.0.0-microsvc-fat.jar:?] > at >
[jira] [Resolved] (CXF-7669) Cxf encodes escape caracters twice in JDK9.0.5 and JDK8_161
[ https://issues.apache.org/jira/browse/CXF-7669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Kulp resolved CXF-7669. -- Resolution: Fixed > Cxf encodes escape caracters twice in JDK9.0.5 and JDK8_161 > --- > > Key: CXF-7669 > URL: https://issues.apache.org/jira/browse/CXF-7669 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.2 >Reporter: Mark Czubin >Assignee: Daniel Kulp >Priority: Critical > Fix For: 3.2.3 > > Attachments: ExampleService.wsdl > > > When our response text contains escape characters then those will be encoded > twice. > For example when I return "hello > world". Cxf will encode this as "hello &> > world" > {code:java} > hello world{code} > > Below a test with all the interceptors used in our setup on production: > {code:java} > package be.vlaanderen.omgeving.rest.controller.parameter.v1; > import org.apache.cxf.Bus; > import org.apache.cxf.BusFactory; > import org.apache.cxf.binding.Binding; > import org.apache.cxf.binding.BindingFactory; > import org.apache.cxf.binding.BindingFactoryManager; > import org.apache.cxf.binding.soap.SoapMessage; > import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor; > import org.apache.cxf.endpoint.Endpoint; > import org.apache.cxf.endpoint.EndpointException; > import org.apache.cxf.endpoint.EndpointImpl; > import org.apache.cxf.jaxb.JAXBDataBinding; > import org.apache.cxf.message.Exchange; > import org.apache.cxf.message.ExchangeImpl; > import org.apache.cxf.message.MessageImpl; > import org.apache.cxf.phase.PhaseInterceptorChain; > import org.apache.cxf.service.Service; > import org.apache.cxf.service.model.BindingOperationInfo; > import org.apache.cxf.service.model.EndpointInfo; > import org.apache.cxf.staxutils.StaxUtils; > import org.apache.cxf.wsdl.interceptors.BareOutInterceptor; > import org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor; > import org.apache.cxf.wsdl11.WSDLServiceFactory; > import org.junit.Test; > import javax.xml.bind.JAXBContext; > import javax.xml.bind.JAXBException; > import javax.xml.namespace.QName; > import javax.xml.stream.XMLInputFactory; > import javax.xml.stream.XMLOutputFactory; > import javax.xml.stream.XMLStreamException; > import javax.xml.stream.XMLStreamReader; > import javax.xml.stream.XMLStreamWriter; > import java.io.ByteArrayInputStream; > import java.io.ByteArrayOutputStream; > import java.util.List; > import java.util.TreeSet; > import static java.util.Collections.emptyList; > import static > org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.OUT_BUFFERING; > import static org.assertj.core.api.Assertions.assertThat; > import static org.mockito.BDDMockito.given; > import static org.mockito.Mockito.mock; > public class CxfIsUnstable { > CxfFacade cxf = new CxfFacade(); > @Test > public void > givenAResponseWithAmpersans_whenMarshallingToXml_theAmpersandAreEncoded_onlyOnce() > throws Exception { > cxf.setupExampleService(); > String request = cxf.demarshallRequest("hello > world"); > assertThat(request).isEqualTo("hello & world"); > String responseXml = cxf.marshallResponse("hello & world"); > assertThat(responseXml).isEqualTo("hello > world<"); > } > static class CxfFacade { > private final SAAJOutInterceptor saajOutInterceptor = new > SAAJOutInterceptor(); > private final BareOutInterceptor outInterceptor = new > BareOutInterceptor(); > private final DocLiteralInInterceptor inInterceptor = new > DocLiteralInInterceptor(); > private SoapMessage message; > private List messageContents; > public String demarshallRequest(String input) throws > XMLStreamException { > message.setContent(XMLStreamReader.class, > XMLInputFactory.newInstance().createXMLStreamReader(new > ByteArrayInputStream(input.getBytes(; > > StaxUtils.skipToStartOfElement(message.getContent(XMLStreamReader.class)); > inInterceptor.handleMessage(message); > assertThat(message.getContent(Exception.class)).isNull(); > messageContents = message.getContent(List.class); > String requestContent = (String) messageContents.get(0); > saajOutInterceptor.handleMessage(message); > return requestContent; > } > public String marshallResponse(String responseBody) throws Exception { > messageContents.set(0, responseBody); > ByteArrayOutputStream boas = new ByteArrayOutputStream(); > XMLOutputFactory xmlOutputFactory = > XMLOutputFactory.newInstance(); > XMLStreamWriter output = > xmlOutputFactory.createXMLStreamWriter(boas); > message.setContent(XMLStreamWriter.class, output); >
[jira] [Updated] (CXF-7669) Cxf encodes escape caracters twice in JDK9.0.5 and JDK8_161
[ https://issues.apache.org/jira/browse/CXF-7669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Kulp updated CXF-7669: - Fix Version/s: (was: NeedMoreInfo) 3.2.3 > Cxf encodes escape caracters twice in JDK9.0.5 and JDK8_161 > --- > > Key: CXF-7669 > URL: https://issues.apache.org/jira/browse/CXF-7669 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.2 >Reporter: Mark Czubin >Assignee: Daniel Kulp >Priority: Critical > Fix For: 3.2.3 > > Attachments: ExampleService.wsdl > > > When our response text contains escape characters then those will be encoded > twice. > For example when I return "hello > world". Cxf will encode this as "hello &> > world" > {code:java} > hello world{code} > > Below a test with all the interceptors used in our setup on production: > {code:java} > package be.vlaanderen.omgeving.rest.controller.parameter.v1; > import org.apache.cxf.Bus; > import org.apache.cxf.BusFactory; > import org.apache.cxf.binding.Binding; > import org.apache.cxf.binding.BindingFactory; > import org.apache.cxf.binding.BindingFactoryManager; > import org.apache.cxf.binding.soap.SoapMessage; > import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor; > import org.apache.cxf.endpoint.Endpoint; > import org.apache.cxf.endpoint.EndpointException; > import org.apache.cxf.endpoint.EndpointImpl; > import org.apache.cxf.jaxb.JAXBDataBinding; > import org.apache.cxf.message.Exchange; > import org.apache.cxf.message.ExchangeImpl; > import org.apache.cxf.message.MessageImpl; > import org.apache.cxf.phase.PhaseInterceptorChain; > import org.apache.cxf.service.Service; > import org.apache.cxf.service.model.BindingOperationInfo; > import org.apache.cxf.service.model.EndpointInfo; > import org.apache.cxf.staxutils.StaxUtils; > import org.apache.cxf.wsdl.interceptors.BareOutInterceptor; > import org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor; > import org.apache.cxf.wsdl11.WSDLServiceFactory; > import org.junit.Test; > import javax.xml.bind.JAXBContext; > import javax.xml.bind.JAXBException; > import javax.xml.namespace.QName; > import javax.xml.stream.XMLInputFactory; > import javax.xml.stream.XMLOutputFactory; > import javax.xml.stream.XMLStreamException; > import javax.xml.stream.XMLStreamReader; > import javax.xml.stream.XMLStreamWriter; > import java.io.ByteArrayInputStream; > import java.io.ByteArrayOutputStream; > import java.util.List; > import java.util.TreeSet; > import static java.util.Collections.emptyList; > import static > org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.OUT_BUFFERING; > import static org.assertj.core.api.Assertions.assertThat; > import static org.mockito.BDDMockito.given; > import static org.mockito.Mockito.mock; > public class CxfIsUnstable { > CxfFacade cxf = new CxfFacade(); > @Test > public void > givenAResponseWithAmpersans_whenMarshallingToXml_theAmpersandAreEncoded_onlyOnce() > throws Exception { > cxf.setupExampleService(); > String request = cxf.demarshallRequest("hello > world"); > assertThat(request).isEqualTo("hello & world"); > String responseXml = cxf.marshallResponse("hello & world"); > assertThat(responseXml).isEqualTo("hello > world<"); > } > static class CxfFacade { > private final SAAJOutInterceptor saajOutInterceptor = new > SAAJOutInterceptor(); > private final BareOutInterceptor outInterceptor = new > BareOutInterceptor(); > private final DocLiteralInInterceptor inInterceptor = new > DocLiteralInInterceptor(); > private SoapMessage message; > private List messageContents; > public String demarshallRequest(String input) throws > XMLStreamException { > message.setContent(XMLStreamReader.class, > XMLInputFactory.newInstance().createXMLStreamReader(new > ByteArrayInputStream(input.getBytes(; > > StaxUtils.skipToStartOfElement(message.getContent(XMLStreamReader.class)); > inInterceptor.handleMessage(message); > assertThat(message.getContent(Exception.class)).isNull(); > messageContents = message.getContent(List.class); > String requestContent = (String) messageContents.get(0); > saajOutInterceptor.handleMessage(message); > return requestContent; > } > public String marshallResponse(String responseBody) throws Exception { > messageContents.set(0, responseBody); > ByteArrayOutputStream boas = new ByteArrayOutputStream(); > XMLOutputFactory xmlOutputFactory = > XMLOutputFactory.newInstance(); > XMLStreamWriter output = > xmlOutputFactory.createXMLStreamWriter(boas); >
[jira] [Commented] (CXF-5052) Classpath references should be understood using wsdlRoot batch processing options in cxf-codegen
[ https://issues.apache.org/jira/browse/CXF-5052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16401793#comment-16401793 ] Oliver commented on CXF-5052: - Just a short information: I did not find the time to proceed with this, but I did not forget. I hope to proceed with this at the weekend. > Classpath references should be understood using wsdlRoot batch processing > options in cxf-codegen > > > Key: CXF-5052 > URL: https://issues.apache.org/jira/browse/CXF-5052 > Project: CXF > Issue Type: Improvement > Components: Tooling >Affects Versions: 2.7.5 > Environment: All >Reporter: Zach Melnick >Priority: Major > > The generated client code should be able to reference a relative classpath > rather than an absolute one when using the wsdlRoot option to generate > clients and services via the cxf-codegen plugin. > Relative classpaths can be specified when using the non-batch processing > wsdlLocation options. This can be done when using something like > classpath:wsdl/foo.wsdl. > However, using the classpath reference in wsdlRoot does not work in the same > fashion. > classpath:wsdl/ should be able to find the wsdl > directory in ${basedir}/src/main/resources/wsdl, and generate the clients > with a wsdlLocation value relative to the classpath, making the behavior > between and consistant. -- This message was sent by Atlassian JIRA (v7.6.3#76005)