1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+
16
17
package org .springframework .mock .http .client ;
17
18
18
19
import java .io .IOException ;
@@ -39,7 +40,7 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie
39
40
*/
40
41
public MockClientHttpResponse (byte [] body , HttpStatus statusCode ) {
41
42
super (body );
42
- Assert .notNull (statusCode , "statisCode is required" );
43
+ Assert .notNull (statusCode , "HttpStatus is required" );
43
44
this .status = statusCode ;
44
45
}
45
46
@@ -48,10 +49,11 @@ public MockClientHttpResponse(byte[] body, HttpStatus statusCode) {
48
49
*/
49
50
public MockClientHttpResponse (InputStream body , HttpStatus statusCode ) {
50
51
super (body );
51
- Assert .notNull (statusCode , "statisCode is required" );
52
+ Assert .notNull (statusCode , "HttpStatus is required" );
52
53
this .status = statusCode ;
53
54
}
54
55
56
+
55
57
@ Override
56
58
public HttpStatus getStatusCode () throws IOException {
57
59
return this .status ;
@@ -69,6 +71,15 @@ public String getStatusText() throws IOException {
69
71
70
72
@ Override
71
73
public void close () {
74
+ try {
75
+ InputStream body = getBody ();
76
+ if (body != null ) {
77
+ body .close ();
78
+ }
79
+ }
80
+ catch (IOException ex ) {
81
+ // ignore
82
+ }
72
83
}
73
84
74
85
}
0 commit comments