11/*
2- * Copyright 2002-2012 the original author or authors.
2+ * Copyright 2002-2016 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16+
1617package org .springframework .mock .http .client ;
1718
1819import java .io .IOException ;
@@ -39,7 +40,7 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie
3940 */
4041 public MockClientHttpResponse (byte [] body , HttpStatus statusCode ) {
4142 super (body );
42- Assert .notNull (statusCode , "statisCode is required" );
43+ Assert .notNull (statusCode , "HttpStatus is required" );
4344 this .status = statusCode ;
4445 }
4546
@@ -48,10 +49,11 @@ public MockClientHttpResponse(byte[] body, HttpStatus statusCode) {
4849 */
4950 public MockClientHttpResponse (InputStream body , HttpStatus statusCode ) {
5051 super (body );
51- Assert .notNull (statusCode , "statisCode is required" );
52+ Assert .notNull (statusCode , "HttpStatus is required" );
5253 this .status = statusCode ;
5354 }
5455
56+
5557 @ Override
5658 public HttpStatus getStatusCode () throws IOException {
5759 return this .status ;
@@ -69,6 +71,15 @@ public String getStatusText() throws IOException {
6971
7072 @ Override
7173 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+ }
7283 }
7384
7485}
0 commit comments