Skip to content

Commit ba6d9e7

Browse files
committed
SWS-245, for real this time, in 1.0 branch
1 parent e2e95b1 commit ba6d9e7

File tree

6 files changed

+53
-12
lines changed

6 files changed

+53
-12
lines changed

core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,8 @@ public Object sendAndReceive(String uri,
413413
return handleFault(connection, request, response);
414414
}
415415
else {
416-
Object extracted = responseExtractor.extractData(response);
417416
logResponse(request, response);
418-
return extracted;
417+
return responseExtractor.extractData(response);
419418
}
420419
}
421420
else {

core/src/main/java/org/springframework/ws/transport/AbstractReceiverConnection.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ protected final TransportOutputStream createTransportOutputStream() throws IOExc
4747
return responseOutputStream;
4848
}
4949

50+
public final void close() throws IOException {
51+
try {
52+
if (requestInputStream != null) {
53+
requestInputStream.close();
54+
}
55+
}
56+
finally {
57+
onClose();
58+
}
59+
}
60+
61+
/**
62+
* Template method invoked from {@link #close()}. Default implementation is empty.
63+
*
64+
* @throws IOException if an I/O error occurs when closing this connection
65+
*/
66+
protected void onClose() throws IOException {
67+
}
68+
5069
/**
5170
* Returns an iteration over all the header names this request contains. Returns an empty <code>Iterator</code> if
5271
* there areno headers.
@@ -89,6 +108,11 @@ public Iterator getHeaders(String name) throws IOException {
89108
return getRequestHeaders(name);
90109
}
91110

111+
public void close() throws IOException {
112+
// defer close, some SoapMessage implementations (Axis) lazy-initialize the SOAPMessage
113+
}
114+
115+
92116
}
93117

94118
/** Implementation of <code>TransportOutputStream</code> for sending-side connections. */

core/src/main/java/org/springframework/ws/transport/AbstractSenderConnection.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ protected final TransportInputStream createTransportInputStream() throws IOExcep
5252
}
5353
}
5454

55+
public final void close() throws IOException {
56+
try {
57+
if (responseInputStream != null) {
58+
responseInputStream.close();
59+
}
60+
}
61+
finally {
62+
onClose();
63+
}
64+
}
65+
66+
/**
67+
* Template method invoked from {@link #close()}. Default implementation is empty.
68+
*
69+
* @throws IOException if an I/O error occurs when closing this connection
70+
*/
71+
protected void onClose() throws IOException {
72+
}
73+
5574
/** Indicates whether this connection has a response. */
5675
protected abstract boolean hasResponse() throws IOException;
5776

@@ -109,6 +128,10 @@ public Iterator getHeaders(String name) throws IOException {
109128
return getResponseHeaders(name);
110129
}
111130

131+
public void close() throws IOException {
132+
// defer close, some SoapMessage implementations (Axis) lazy-initialize the SOAPMessage
133+
}
134+
112135
}
113136

114137
}

core/src/main/java/org/springframework/ws/transport/http/CommonsHttpConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.commons.httpclient.HttpClient;
2828
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
2929
import org.apache.commons.httpclient.methods.PostMethod;
30+
3031
import org.springframework.util.Assert;
3132
import org.springframework.ws.WebServiceMessage;
3233
import org.springframework.ws.transport.WebServiceConnection;
@@ -57,7 +58,7 @@ public PostMethod getPostMethod() {
5758
return postMethod;
5859
}
5960

60-
public void close() throws IOException {
61+
public void onClose() throws IOException {
6162
postMethod.releaseConnection();
6263
}
6364

core/src/main/java/org/springframework/ws/transport/http/HttpServletConnection.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.ws.transport.http;
1818

19-
import java.io.FilterInputStream;
2019
import java.io.IOException;
2120
import java.io.InputStream;
2221
import java.io.OutputStream;
@@ -91,12 +90,7 @@ protected Iterator getRequestHeaders(String name) throws IOException {
9190
}
9291

9392
protected InputStream getRequestInputStream() throws IOException {
94-
return new FilterInputStream(getHttpServletRequest().getInputStream()) {
95-
96-
public void close() throws IOException {
97-
// defer close, some SAAJ implementations (Axis 1) lazy-initialize the SOAPMessage
98-
}
99-
};
93+
return getHttpServletRequest().getInputStream();
10094
}
10195

10296
/*
@@ -115,7 +109,7 @@ protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
115109
statusCodeSet = true;
116110
}
117111

118-
public void close() throws IOException {
112+
public void onClose() throws IOException {
119113
if (!statusCodeSet) {
120114
getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_ACCEPTED);
121115
}

core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public HttpURLConnection getConnection() {
5555
return connection;
5656
}
5757

58-
public void close() {
58+
public void onClose() {
5959
connection.disconnect();
6060
}
6161

0 commit comments

Comments
 (0)