Closed as not planned
Closed as not planned
Description
In Spring Framework 6.1 M3, using BufferingClientHttpRequestFactory
with JdkClientHttpRequestFactory
throws an exception
java.lang.IllegalArgumentException: non-positive contentLength: 0
.
The issue seems to be from class BufferingClientHttpResponseWrapper
, method
@Override
public InputStream getBody() throws IOException {
if (this.body == null) {
this.body = StreamUtils.copyToByteArray(this.response.getBody())
}
return new ByteArrayInputStream(this.body);
}
Since BufferingClientHttpResponseWrapper
is not public
, I copied the class and was able to fix the issue with
@Override
public InputStream getBody() throws IOException {
if (this.body == null) {
this.body = StreamUtils.copyToByteArray((this.response.getBody() != null) ? this.response.getBody() : new ByteArrayInputStream(new byte[0]));
}
return new ByteArrayInputStream(this.body);
}
Not sure if this is a good fix but it works.