Author: dkulp
Date: Tue Jan 12 20:56:38 2010
New Revision: 898509
URL: http://svn.apache.org/viewvc?rev=898509&view=rev
Log:
[CXF-2466] Clean up stack traces from retransmit issues
Also fix problems with SequenceTest running in my eclipse workspace.
This MAY fix the random failures in some of the SequenceTests
Modified:
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java
Modified:
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java?rev=898509&r1=898508&r2=898509&view=diff
==============================================================================
---
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java
(original)
+++
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java
Tue Jan 12 20:56:38 2010
@@ -48,7 +48,7 @@
}
public void onClose(CachedOutputStream cos) {
- //REVISIT - would be nice to keep the cache on disk intead of
in-memory
+ //REVISIT - would be nice to keep the cache on disk instead of
in-memory
byte bytes[] = null;
try {
bytes = cos.getBytes();
Modified:
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java?rev=898509&r1=898508&r2=898509&view=diff
==============================================================================
---
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
(original)
+++
cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
Tue Jan 12 20:56:38 2010
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
+import java.net.ConnectException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -262,6 +263,10 @@
if (null != maps) {
to = maps.getTo();
}
+ if
(RMUtils.getAddressingConstants().getAnonymousURI().equals(to.getValue())) {
+ LOG.log(Level.FINE, "Cannot resend to anonymous target");
+ return;
+ }
if (null == to) {
LOG.log(Level.SEVERE, "NO_ADDRESS_FOR_RESEND_MSG");
return;
@@ -317,10 +322,11 @@
if (os instanceof CachedOutputStream) {
callbacks = ((CachedOutputStream)os).getCallbacks();
}
-
+ message.removeContent(OutputStream.class);
c.prepare(message);
os = message.getContent(OutputStream.class);
+
if (null != callbacks && callbacks.size() > 1) {
if (!(os instanceof CachedOutputStream)) {
os = RMUtils.createCachedStream(message, os);
@@ -349,6 +355,8 @@
IOUtils.copyAndCloseInput(bis, os);
os.flush();
os.close();
+ } catch (ConnectException ex) {
+ //ignore, we'll just resent again later
} catch (IOException ex) {
LOG.log(Level.SEVERE, "RESEND_FAILED_MSG", ex);
}
@@ -359,6 +367,7 @@
*/
protected class ResendCandidate implements Runnable {
private Message message;
+ private OutputStream out;
private Date next;
private TimerTask nextTask;
private int resends;
@@ -373,6 +382,7 @@
protected ResendCandidate(Message m) {
message = m;
resends = 0;
+ out = m.getContent(OutputStream.class);
RMAssertion rma =
PolicyUtils.getRMAssertion(manager.getRMAssertion(), message);
long baseRetransmissionInterval =
rma.getBaseRetransmissionInterval().getMilliseconds().longValue();
@@ -380,6 +390,18 @@
? RetransmissionQueue.DEFAULT_EXPONENTIAL_BACKOFF : 1;
next = new Date(System.currentTimeMillis() +
baseRetransmissionInterval);
nextInterval = baseRetransmissionInterval * backoff;
+
+
+ AddressingProperties maps = RMContextUtils.retrieveMAPs(message,
false, true);
+ AttributedURIType to = null;
+ if (null != maps) {
+ to = maps.getTo();
+ }
+ if (to != null
+ &&
RMUtils.getAddressingConstants().getAnonymousURI().equals(to.getValue())) {
+ LOG.log(Level.INFO, "Cannot resend to anonymous target. Not
scheduling a resend.");
+ return;
+ }
if (null != manager.getTimer()) {
schedule();
}
@@ -415,6 +437,7 @@
// ensure ACK wasn't received while this task was enqueued
// on executor
if (isPending()) {
+ message.setContent(OutputStream.class, out);
resender.resend(message, includeAckRequested);
includeAckRequested = false;
}
Modified:
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?rev=898509&r1=898508&r2=898509&view=diff
==============================================================================
---
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
(original)
+++
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
Tue Jan 12 20:56:38 2010
@@ -188,7 +188,6 @@
}
// --- tests ---
-
@Test
public void testOnewayAnonymousAcks() throws Exception {
init("org/apache/cxf/systest/ws/rm/rminterceptors.xml");
@@ -642,16 +641,14 @@
}
- /**
- * A maximum sequence length of 2 is configured for the client only
(server allows 10).
- * However, as we use the defaults regarding the including and acceptance
- * for inbound sequence offers and correlate offered sequences that are
- * included in a CreateSequence request and accepted with those that are
- * created on behalf of such a request, the server also tries terminate its
- * sequences. Note that as part of the sequence termination exchange a
- * standalone sequence acknowledgment needs to be sent regardless of
whether
- * or nor acknowledgments are delivered steadily with every response.
- */
+ // A maximum sequence length of 2 is configured for the client only
(server allows 10).
+ // However, as we use the defaults regarding the including and acceptance
+ // for inbound sequence offers and correlate offered sequences that are
+ // included in a CreateSequence request and accepted with those that are
+ // created on behalf of such a request, the server also tries terminate its
+ // sequences. Note that as part of the sequence termination exchange a
+ // standalone sequence acknowledgment needs to be sent regardless of
whether
+ // or nor acknowledgments are delivered steadily with every response.
@Test
public void testTwowayNonAnonymousMaximumSequenceLength2() throws
Exception {
init("org/apache/cxf/systest/ws/rm/seqlength10.xml", true);
@@ -1322,7 +1319,6 @@
mf.verifyAcknowledgements(new boolean[] {false, true}, false);
}
-
// --- test utilities ---
private void init(String cfgResource) {
Modified:
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java?rev=898509&r1=898508&r2=898509&view=diff
==============================================================================
---
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java
(original)
+++
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java
Tue Jan 12 20:56:38 2010
@@ -20,8 +20,8 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -40,7 +40,7 @@
public InMessageRecorder() {
super(Phase.RECEIVE);
- inbound = new ArrayList<byte[]>();
+ inbound = new CopyOnWriteArrayList<byte[]>();
}
public void handleMessage(Message message) throws Fault {
Modified:
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java?rev=898509&r1=898508&r2=898509&view=diff
==============================================================================
---
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java
(original)
+++
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java
Tue Jan 12 20:56:38 2010
@@ -20,8 +20,8 @@
package org.apache.cxf.systest.ws.util;
import java.io.OutputStream;
-import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -48,12 +48,13 @@
public OutMessageRecorder() {
super(Phase.PRE_STREAM);
- outbound = new ArrayList<byte[]>();
+ outbound = new CopyOnWriteArrayList<byte[]>();
addAfter(RetransmissionInterceptor.class.getName());
addBefore(StaxOutInterceptor.class.getName());
}
public void handleMessage(Message message) throws Fault {
+
OutputStream os = message.getContent(OutputStream.class);
if (null == os) {
return;