Skip to content

Performance: JsonHttpContent.writeTo() is called twice for each HttpRequest #283

@siom79

Description

@siom79

Debugging shows that the method JsonHttpContent.writeTo() is called twice when a HttpRequest is rendered. For the first time it is called to compute the length of the body and for the second time to actually render the JSON string.

First invocation:

"main@1" prio=5 tid=0x1 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at com.google.api.client.http.json.JsonHttpContent.writeTo(JsonHttpContent.java:73)
      at com.google.api.client.util.IOUtils.computeLength(IOUtils.java:113)
      at com.google.api.client.http.AbstractHttpContent.computeLength(AbstractHttpContent.java:139)
      at com.google.api.client.http.AbstractHttpContent.computeLength(AbstractHttpContent.java:117)
      at com.google.api.client.http.AbstractHttpContent.getLength(AbstractHttpContent.java:65)
      at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:914)

Second invocation:

"main@1" prio=5 tid=0x1 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at com.google.api.client.http.json.JsonHttpContent.writeTo(JsonHttpContent.java:73)
      at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:79)
      at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:965)

Metadata

Metadata

Assignees

Labels

type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions