MockHttpInputMessage respects getBody contract

Issue: SPR-16367
This commit is contained in:
Rossen Stoyanchev
2018-01-12 11:44:42 -05:00
parent 1b3b058ebd
commit 03118542f4
2 changed files with 4 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class MockHttpInputMessage implements HttpInputMessage {
public MockHttpInputMessage(byte[] contents) {
this.body = (contents != null ? new ByteArrayInputStream(contents) : null);
this.body = new ByteArrayInputStream(contents != null ? contents : new byte[0]);
}
public MockHttpInputMessage(InputStream body) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,10 +72,7 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie
@Override
public void close() {
try {
InputStream body = getBody();
if (body != null) {
body.close();
}
getBody().close();
}
catch (IOException ex) {
// ignore