Skip to content

"Premature end of chunk coded message body" and TruncatedChunkException when calling HttpResponse.disconnect() #1409

Description

@joaomagalhaes

Environment details

Using:
com.google.apis:google-api-services-androidpublisher:v3-rev142-1.25.0
com.google.http-client:google-http-client:1.39.2

  1. OS type and version: OS Big Sur (11.2.3)
  2. Java version: OpenJDK Runtime Environment Corretto-11.0.10.9.1 (build 11.0.10+9-LTS)
  3. google-http-client version(s): 1.39.1 and 1.39.2

Steps to reproduce

Call com.google.api.client.http.HttpResponse.disconnect() after com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed()

Code example

final AndroidPublisher.Inappproducts inAppProductsApi = this.publisherApiClient.inappproducts();
final AndroidPublisher.Inappproducts.List list = inAppProductsApi.list(this.packageName);

final HttpResponse httpResponse = list.executeUnparsed();
final int statusCode = httpResponse.getStatusCode();
httpResponse.disconnect();

Stack trace

http-outgoing-0 >> GET /androidpublisher/v3/applications/{package_name}/inappproducts HTTP/1.1
http-outgoing-0 >> User-Agent: Google-API-Java-Client Google-HTTP-Java-Client/1.39.2 (gzip)
headers|http-outgoing-0 >> Host: www.googleapis.com
headers|http-outgoing-0 >> Connection: Keep-Alive

headers|http-outgoing-0 << HTTP/1.1 200 OK
headers|http-outgoing-0 << Content-Type: application/json; charset=UTF-8
headers|http-outgoing-0 << Content-Encoding: gzip
headers|http-outgoing-0 << Transfer-Encoding: chunked

MainClientExec|Connection can be kept alive indefinitely
MainClientExec|Cancelling request execution
DefaultManagedHttpClientConnection|http-outgoing-0: Shutdown connection
MainClientExec|Connection discarded
PoolingHttpClientConnectionManager|Connection released: [id: 0][route: {s}->https://www.googleapis.com:443][total available: 0; route allocated: 0 of 20; total allocated: 0 of 200]

org.apache.http.TruncatedChunkException: Truncated chunk (expected size: 974; actual size: 595)
	at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:197) ~[httpcore-4.4.14.jar:4.4.14]
	at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:210) ~[httpcore-4.4.14.jar:4.4.14]
	at org.apache.http.impl.io.ChunkedInputStream.close(ChunkedInputStream.java:312) ~[httpcore-4.4.14.jar:4.4.14]
	at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:142) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:172) ~[httpclient-4.5.13.jar:4.5.13]
	at org.apache.http.client.entity.LazyDecompressingInputStream.close(LazyDecompressingInputStream.java:97) ~[httpclient-4.5.13.jar:4.5.13]
	at com.google.api.client.http.HttpResponse.ignore(HttpResponse.java:427) ~[google-http-client-1.39.2.jar:1.39.2]
	at com.google.api.client.http.HttpResponse.disconnect(HttpResponse.java:441) ~[google-http-client-1.39.2.jar:1.39.2]

Any additional information below

Does not happen on 1.39.0. The change that cause the issue was f84ed59

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions