Skip to content

HttpSenderConnection attempts to decode gzip response, even it is already decoded #1754

@codingtim

Description

@codingtim

We just upgraded apache http client to 5.6 release.
This results in our tests failing.
Trace:

Caused by: java.util.zip.ZipException: Not in GZIP format
	at java.base/java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:197)
	at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
	at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:112)
	at org.springframework.ws.transport.http.AbstractHttpSenderConnection.getResponseInputStream(AbstractHttpSenderConnection.java:109)
	at org.springframework.ws.transport.AbstractSenderConnection$ResponseTransportInputStream.createInputStream(AbstractSenderConnection.java:97)
	at org.springframework.ws.transport.TransportInputStream.getInputStream(TransportInputStream.java:44)
	at org.springframework.ws.transport.TransportInputStream.read(TransportInputStream.java:89)
	at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:291)
	at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:347)
	at java.base/java.io.BufferedInputStream.implRead(BufferedInputStream.java:420)
	at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:399)
	at java.base/java.io.FilterInputStream.read(FilterInputStream.java:119)
	at java.base/java.io.PushbackInputStream.read(PushbackInputStream.java:197)
	at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.checkForUtf8ByteOrderMark(SaajSoapMessageFactory.java:282)
	at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:196)
	at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:66)
	at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:89)
	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:634)
	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:575)

The issue is caused by commit in http client:
apache/httpcomponents-client@56122fd

Http client always decoded gzip and (until 5.6 release) removed the relevant http headers.
Since release 5.6 http client no longer removes the encoding http headers.
The AbstractHttpSenderConnection.getResponseInputStream method now sees the encoding header and creates GZIPInputStream which throws the error as the inputstream was already decoded.
https://github.com/spring-projects/spring-ws/blob/main/spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpSenderConnection.java#L111

Is there any way spring-ws can support this new http client behavior?

Possible workarounds for users:

Metadata

Metadata

Assignees

Labels

status: on-holdWe can't start working on this issue yettype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions