MockHttpInputMessage respects getBody contract
Issue: SPR-16367
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user