artiya4u / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

ClassCastException in ApacheHttpRequest.setContent #122

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.5.0-beta)?

1.9.0-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?

Android 2.2 (Froyo)

Describe the problem.

See:
https://groups.google.com/forum/?fromgroups#!topic/google-http-java-client/32ZFW
eaAyVM

stack trace copied here:

05-23 13:15:00.526: W/System.err(1168): java.lang.ClassCastException: 
org.apache.http.client.methods.HttpGet
05-23 13:15:00.537: W/System.err(1168):     at 
com.google.api.client.http.apache.ApacheHttpRequest.setContent(ApacheHttpRequest
.java:66)
05-23 13:15:00.537: W/System.err(1168):     at 
com.google.api.client.http.HttpRequest.execute(HttpRequest.java:805)

How would you expect it to be fixed?

It is very rare to see an HTTP GET request with content.  It is not strictly 
forbidden though, see:
http://tech.groups.yahoo.com/group/rest-discuss/message/9962

Problem is that the Apache HTTP Client just doesn't support that use case.  So 
at least we should throw a nice IllegalArgumentException with an explanation 
instead of a ClassCastException.

A nicer option is that we could actually work around the limitation like we've 
done with HttpPatch.  It should be easy enough to implement, but given how rare 
it is, it might not be important enough to fix.

Original issue reported on code.google.com by yan...@google.com on 29 May 2012 at 6:20

GoogleCodeExporter commented 9 years ago
http://codereview.appspot.com/6450137/

Original comment by rmis...@google.com on 15 Aug 2012 at 12:28

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 22 Aug 2012 at 8:40