Skip to content
Permalink
Browse files
[CXF-5434] Fix some issues where a reply may attempt to be sent to th…
…e "none" address.

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1548739 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Dec 6, 2013
1 parent 4d392f1 commit ee1f819312ab69397fd155ea0e03e495776a73ce
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 43 deletions.
@@ -62,6 +62,9 @@ public void handleMessage(Message message) {

boolean output = false;
if (!isRequestor(message)) {
if (operation.getOutput() == null) {
return;
}
parts = operation.getOutput().getMessageParts();
output = true;
} else {
@@ -76,7 +76,11 @@ private Object retrieveRequestFromStream(boolean isTextPayload1) throws IOExcept
throw new IOException("Error creating request Object from Message content, exception " + ex);
}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Payload to be sent out is :[" + request + "]");
Object o = request;
if (o instanceof byte[]) {
o = new String((byte[])o, "utf-8");
}
LOG.log(Level.FINE, "Payload to be sent out is :[" + o + "]");
}
return request;
}
@@ -75,6 +75,61 @@
* Holder for utility methods relating to contexts.
*/
final class InternalContextUtils {
private static final class DecoupledDestination implements Destination {
private final EndpointInfo ei;
private final EndpointReferenceType reference;

private DecoupledDestination(EndpointInfo ei, EndpointReferenceType reference) {
this.ei = ei;
this.reference = reference;
}

public EndpointReferenceType getAddress() {
return reference;
}

public Conduit getBackChannel(Message inMessage) throws IOException {
if (ContextUtils.isNoneAddress(reference)) {
return null;
}
Bus bus = inMessage.getExchange().get(Bus.class);
//this is a response targeting a decoupled endpoint. Treat it as a oneway so
//we don't wait for a response.
inMessage.getExchange().setOneWay(true);
ConduitInitiator conduitInitiator
= bus.getExtension(ConduitInitiatorManager.class)
.getConduitInitiatorForUri(reference.getAddress().getValue());
if (conduitInitiator != null) {
Conduit c = conduitInitiator.getConduit(ei, reference, bus);
// ensure decoupled back channel input stream is closed
c.setMessageObserver(new MessageObserver() {
public void onMessage(Message m) {
InputStream is = m.getContent(InputStream.class);
if (is != null) {
try {
is.close();
} catch (Exception e) {
// ignore
}
}
}
});
return c;
}
return null;
}

public MessageObserver getMessageObserver() {
return null;
}

public void shutdown() {
}

public void setMessageObserver(MessageObserver observer) {
}
}

private static final Logger LOG = LogUtils.getL7dLogger(InternalContextUtils.class);

/**
@@ -286,47 +341,8 @@ public void run() {

public static Destination createDecoupledDestination(
Exchange exchange, final EndpointReferenceType reference) {

final EndpointInfo ei = exchange.get(Endpoint.class).getEndpointInfo();
return new Destination() {
public EndpointReferenceType getAddress() {
return reference;
}
public Conduit getBackChannel(Message inMessage) throws IOException {
Bus bus = inMessage.getExchange().get(Bus.class);
//this is a response targeting a decoupled endpoint. Treat it as a oneway so
//we don't wait for a response.
inMessage.getExchange().setOneWay(true);
ConduitInitiator conduitInitiator
= bus.getExtension(ConduitInitiatorManager.class)
.getConduitInitiatorForUri(reference.getAddress().getValue());
if (conduitInitiator != null) {
Conduit c = conduitInitiator.getConduit(ei, reference, bus);
// ensure decoupled back channel input stream is closed
c.setMessageObserver(new MessageObserver() {
public void onMessage(Message m) {
InputStream is = m.getContent(InputStream.class);
if (is != null) {
try {
is.close();
} catch (Exception e) {
// ignore
}
}
}
});
return c;
}
return null;
}
public MessageObserver getMessageObserver() {
return null;
}
public void shutdown() {
}
public void setMessageObserver(MessageObserver observer) {
}
};
return new DecoupledDestination(ei, reference);
}

/**
@@ -19,6 +19,7 @@
package org.apache.cxf.systest.jms;

import javax.jws.WebService;
import javax.xml.ws.soap.Addressing;

import org.apache.cxf.hello_world_jms.HelloWorldOneWayPort;

@@ -29,6 +30,7 @@
endpointInterface = "org.apache.cxf.hello_world_jms.HelloWorldOneWayPort",
targetNamespace = "http://cxf.apache.org/hello_world_jms",
wsdlLocation = "testutils/jms_test.wsdl")
@Addressing(required = true)
public class GreeterImplQueueOneWay implements HelloWorldOneWayPort {

public void greetMeOneWay(String stringParam0) {
@@ -40,10 +40,10 @@
import javax.xml.ws.Endpoint;
import javax.xml.ws.Holder;
import javax.xml.ws.Response;
import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.soap.SOAPFaultException;


import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.binding.soap.interceptor.TibcoSoapActionInterceptor;
@@ -93,6 +93,7 @@
import org.apache.hello_world_doc_lit.PingMeFault;
import org.apache.hello_world_doc_lit.SOAPService2;
import org.apache.hello_world_doc_lit.SOAPService7;

import org.junit.BeforeClass;
import org.junit.Test;

@@ -542,7 +543,8 @@ public void testOneWayQueueConnection() throws Exception {
assertNotNull(service);

try {
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class,
new AddressingFeature(true, true));
for (int idx = 0; idx < 5; idx++) {
greeter.greetMeOneWay("JMS:Queue:Milestone-" + idx);
}

0 comments on commit ee1f819

Please sign in to comment.