Git Product home page Git Product logo

google-http-java-client's People

Contributors

rmistry avatar ngmiceli-g avatar peleyal avatar anthmgoogle avatar brendandburns avatar imjasonh avatar

Watchers

 avatar

google-http-java-client's Issues

Provide a way to customize SSL certificate validation

External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

By default we should enable SSL certificate validation.  But we should also 
provide a way to disable SSL certificate validation as a temporary work-around 
for example in case an SSL certificate has expired on a local service I'm 
working on.

Original issue reported on code.google.com by [email protected] on 11 May 2011 at 3:36

XML: handle empty string for numeric value

Copied from:
http://code.google.com/p/google-api-java-client/issues/detail?id=178

Reported by [email protected], Apr 13, 2011
I have a class that maps an XML attribue to a BigDecimal.

public class SalesTaxRate
{
    @Key("@rate")
    public BigDecimal totalRate;
}

I don't have any control over the web service that I'm calling, but I noticed 
that they sometimes send an empty attribute value for "rate" and when 
google-api-java-client tries to map the empty string to a BigDecimal, a 
NumberFormatException is thrown.

<response rate="" />

Partial stacktrace:

java.lang.NumberFormatException
    at java.math.BigDecimal.<init>(BigDecimal.java:457)
    at java.math.BigDecimal.<init>(BigDecimal.java:647)
    at com.google.api.client.util.FieldInfo.parsePrimitiveValue(FieldInfo.java:240)...

Is there a way around this problem without resorting to using String instead of 
BigDecimal?

If not, I would like to request that empty attribute values be mapped to null, 
as though the attribute wasn't present at all. Perhaps there could be an 
annotation to achieve this, if this could not be a global behavior.

Comment 1 by project member [email protected], Apr 13, 2011

Good question.

The only problem I see with setting it to null is that if you later serialize 
the XML you would get:

<response/>

Another option is to set it to 0, but again on serialization you get:

<response rate="0" />

An annotation like @AllowEmptyXMLAttribtue would mean that then there is no way 
to say that this attribute is missing, so if we see this:

<response/>

We will serialize it as:

<response rate="" />

On the other hand, String deals with all of these cases correctly, but it 
requires you to then convert to/from BigDecimal everywhere in your application.

So it seems like no option is really ideal, though I tend to think just setting 
it null might be the most practical option.

By the way, in the case of the web service you are using, how are you supposed 
to interpret rate=""?  Does it mean that the rate is 0, or that the rate is not 
known?  Do you know why they return rate="" instead of the more 
straight-forward choices?

Comment 2 by [email protected], Apr 19, 2011

Thanks for the response. The key issue here for me is that right now, the way 
it works, deserialization can break for an empty XML attribute. I think that no 
matter what a long term solution is, a short term solution should be provided 
so that the NumberFormatException is not thrown, and the BigDecimal (or other 
objects like BigInteger) are deserialized to null.

For a long term solution, we should probably think in terms of how XML schemas 
(or similar mechanisms) define attributes as either "required" or "optional". 
There could be an annotation specifying whether or not an attribute is 
"required" explicitly, so that a required attribute that is null will be 
serialized to an empty attribute value. For the case of BigDecimal, you would 
still need to deserialize to null, even if the XML attribute is empty.

It wouldn't be easy to determine that the original attribute was empty in the 
first place. I guess you could have an annotation that defines a value to set 
the BigDecimal to when the original attribute is empty (e.g., set to minimum 
possible BigDecimal value). To be honest, I'm not sure it is worth it.

To answer your last few questions, the web service interprets rate="" as 
meaning that they can not determine the rate. I think it's just a bad design 
decision on their part (and probably too late to change for them, because I'm 
sure thousands of applications already use their web service).

Original issue reported on code.google.com by [email protected] on 11 May 2011 at 5:02

Move code from generated libraries into the base library

Implement the design proposal here:
http://codereview.appspot.com/5080054/

1. Add JsonHttpRequestInitializer that will be used to initialize requests. E.g 
for setting global parameters.

SampleUsage:

class BooksRequestInitializer implements JsonHttpRequestInitializer {

  public void initialize(GoogleRequest request) {
    BooksRequest booksRequest = (BooksRequest)request;
    booksRequest.setPrettyPrint(true);
    booksRequest.setKey(ClientCredentials.KEY);
  }
}


2. Move as much as possible of the reusable code across the generated
libraries.
Specifically includes the common parts of ApiClient and RemoteRequest.

Example:

final Books books = new Books(new NetHttpTransport(), jsonFactory);
books.setApplicationName("Google-BooksSample/1.0");
books.setKey(ClientCredentials.KEY);

Now becomes:

final Books books = Books.builder(new NetHttpTransport(), jsonFactory)
    .setApplicationName("Google-BooksSample/1.0")
    .setJsonHttpRequestInitializer(new BooksRequestInitializer())
    .build();

3. Follow our thread-safety style guidelines.

Original issue reported on code.google.com by [email protected] on 7 Nov 2011 at 4:57

Deprecate GenericJson.jsonFactory

External references, such as a standards document, or specification?

http://javadoc.google-http-java-client.googlecode.com/hg/1.5.0-beta/com/google/a
pi/client/json/GenericJson.html#jsonFactory

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?

All

Please describe the feature requested.

The new style is to not declare public fields and instead use a private field 
and use getters and setters.  GenericJson.jsonFactory field does no follow this 
style.  We should fix it to fit it with the consistent getter/setter style.

Original issue reported on code.google.com by [email protected] on 9 Sep 2011 at 10:01

When a subclass with a field annotated with @Key hides a superclass field annotated with @Key, prefer the definition from the subclass.

Version of google-http-java-client

The one that's embedded in google-api-java-client 1.4.1-beta


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


Describe the problem.

package my.pkg;

class A {
  @Key
  String foo;
}

class B extends A {
  @Key
  Integer foo;
}

When attempting to anHttpResponse.parseAs(B.class), google-java-api-client 
complains like this:

java.lang.IllegalArgumentException: two fields have the same name <foo>: public 
java.lang.String my.pkg.A.foo and public java.lang.Integer my.pkg.B.foo
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115) ... etc.


How would you expect it to be fixed?

Because the intent of B.foo is to hide A.foo, google-http-java-client should 
only consider B.foo to be of interest for parsing, even though the 
java.lang.reflection API does give it complete information about the 
definitions of foo, and both classes use the @Key annotation.

Original issue reported on code.google.com by [email protected] on 22 Jun 2011 at 3:06

NullPointerException when non-top-level element declares a new namespace and uses it

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.5.0-beta

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

All

Describe the problem.

NullPointerException when namespace is defined on a non-top-level element

Google Document List Feed produces an interior element
<app:edited 
xmlns:app='http://www.w3.org/2007/app'>2011-08-09T04:38:14.017Z</app:edited>

The xmlns:app definition only occurs on this element, not the top-level 
element.  When this is parsed:

java.lang.NullPointerException
        at com.google.api.client.xml.Xml.getFieldName(Xml.java:513)
        at com.google.api.client.xml.Xml.parseElementInternal(Xml.java:317)
        at com.google.api.client.xml.Xml.parseElementInternal(Xml.java:454)
        at com.google.api.client.xml.Xml.parseElement(Xml.java:198)
        at com.google.api.client.http.xml.XmlHttpParser.parse(XmlHttpParser.java:72)
        at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:298)
        at org.springhaven.testing.GdataTest1.main(GdataTest1.java:166)

How would you expect it to be fixed?

Use a namespace stack and duplicate the namespace-addition code in Xml.java 
lines 228-247 at the start of each element (around line 317) to populate the 
stack.

Thanks to [email protected] for reporting!

Original issue reported on code.google.com by [email protected] on 16 Aug 2011 at 2:20

FindBugs found: Synchronization issue in api.client.util.Data

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.5.0-beta

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

All

Describe the problem.

This class is synchronizing on the monitor of a ConcurrentHashMap instance. 
Concurrent objects have their own concurrency controls that are distinct form 
and incompatible with the keyword synchronized. The following function will not 
prevent other threads from making changes to NULL_CHANGE because it uses the 
NULL_CHANGE monitor, while other threads may be using the built-in concurrency 
provided by the collection:

  public static <T> T nullOf(Class<?> objClass) {
    Object result = NULL_CACHE.get(objClass);
    if (result == null) {
      synchronized (NULL_CACHE) {
        result = NULL_CACHE.get(objClass);
        if (result == null) {
          if (objClass.isArray()) {
            // arrays are special because we need to compute both the dimension and component type
            int dims = 0;
            Class<?> componentType = objClass;
            do {
              componentType = componentType.getComponentType();
              dims++;
            } while (componentType.isArray());
            result = Array.newInstance(componentType, new int[dims]);
          } else if (objClass.isEnum()) {
            // enum requires look for constant with @NullValue
            FieldInfo fieldInfo = ClassInfo.of(objClass).getFieldInfo(null);
            Preconditions.checkNotNull(
                fieldInfo, "enum missing constant with @NullValue annotation: %s", objClass);
            @SuppressWarnings({"unchecked", "rawtypes"})
            Enum e = fieldInfo.<Enum>enumValue();
            result = e;
          } else {
            // other classes are simpler
            result = Types.newInstance(objClass);
          }
          NULL_CACHE.put(objClass, result);
        }
      }
    }
    @SuppressWarnings("unchecked")
    T tResult = (T) result;
    return tResult;
  }

FindBugs Output:

Synchronization performed on util.concurrent instance
This method performs synchronization an object that is an instance of a class 
from the java.util.concurrent package (or its subclasses). Instances of these 
classes have there own concurrency control mechanisms that are distinct from 
and incompatible with the use of the keyword synchronized.

How would you expect it to be fixed?


Original issue reported on code.google.com by [email protected] on 16 Aug 2011 at 2:23

HttpContent.getLength() implementation for JSON, XML, URL-encoding, etc.

External references, such as a standards document, or specification?

http://tools.ietf.org/html/rfc2616#section-14.13

"14.13 Content-Length
...
   Applications SHOULD use this field to indicate the transfer-length of
   the message-body, unless this is prohibited by the rules in section
   4.4.
...
   In HTTP, it
   SHOULD be sent whenever the message's length can be determined prior
   to being transferred, unless this is prohibited by the rules in
   section 4.4."

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

We need to be able to compute the content length before we send the content, so 
the getLength() needs to be able to compute the length beforehand.  We will 
provide an AbstractHttpContent that has a default implementation that calls 
writeTo(OutputStream) with a fake output stream that just counts the bytes.

Original issue reported on code.google.com by [email protected] on 24 Jun 2011 at 2:16

How to monitor parsing progress

Original: http://code.google.com/p/google-api-java-client/issues/detail?id=281
Reported by [email protected], Today (48 minutes ago)

Parsing might take log time to. 
Can anyone provide some solution to monitor its progress?

Original issue reported on code.google.com by [email protected] on 25 Aug 2011 at 3:10

FindBugs integration

External references, such as a standards document, or specification?

http://mojo.codehaus.org/findbugs-maven-plugin/

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All.

Please describe the feature requested.

Use FindBugs to find bugs in the code.

Original issue reported on code.google.com by [email protected] on 27 Jul 2011 at 5:56

Write Python scripts to automate some parts of the release process

External references, such as a standards document, or specification?

http://google-http-java-client.googlecode.com/hg/release.html

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?

N/A

Please describe the feature requested.

Some parts of our release process could be automated better, e.g.:
* Forking before release.
* Maven release
* JavaDoc and JDiff generation.

We could use this script (or a copy of it) for our sister projects 
google-oauth-java-client and google-api-java-client.

Original issue reported on code.google.com by [email protected] on 7 Oct 2011 at 4:25

Constructors for required parameters, document thread-safety, use getters/setters

External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

This feature cuts across all areas of the library.  Currently most classes have 
only default parameters.  Any required parameters must be set before calling 
any methods, at which point if any of the required parameters are null we throw 
a NullPointerException.

Instead, we could provide a constructor that has parameters for the required 
fields.  This introduces compile-time checking of those required fields.  We 
might also want constructors that also take optional fields.  Finally, we 
should consider the option to not even provide the default constructor.  A big 
motivation for the switch is thread safety and immutability, and consistency 
throughout the library.

Original issue reported on code.google.com by [email protected] on 11 May 2011 at 3:27

Parsing directly into a List

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?
All


Please describe the feature requested.
JsonParser.parse() can parse in a serialized Map but it cannot parse a List. It 
seems that it's possible to do this by adding simmilar List handling to to what 
it does for Map:

JsonParser.java does this:
     if (!isGenericData && Map.class.isAssignableFrom(destinationClass)) 

It can also do the same for List objects.


Original issue reported on code.google.com by [email protected] on 29 Aug 2011 at 5:23

Extension of GenericData to support handling Protobufs

External references, such as a standards document, or specification?

http://code.google.com/apis/protocolbuffers/docs/overview.html

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

Reported by [email protected], Feb 28, 2011

The GenericData concept is great, and provides a simple way to consume, handle, 
and feed out data in XML/Json formats. As protobuf usage increases as the way 
to pass messages in/out of Java binaries, it would be nice to provide a 
parser/serializer to support translation between protos and GenericData 
(GenericProto?)

I'm not sure how nicely protobufs support this sort of treatment, but at least 
a few of the ideas are the same, e.g.

class Person extends GenericProto {
  @Key
  String name;
  @Key
  long id;
  @Key
  Address address;
}

could be used to automatically load protobufs of the form:

message Address { ... }
message Person {
  required string name = 1;
  required int64 id = 2;
  optional Address address = 3;
}

Original issue reported on code.google.com by [email protected] on 6 Jun 2011 at 1:30

Allow GenericUrl.build() to be overridden

Thanks to [email protected] for reporting the problem!

version: 1.4.1-beta on App Engine 1.5.0.1

As an example of this issue, according to Google's documentation to retrieve 
the ACL Feed for a Google Docs List Entry, the link specified requires the 
form: 

https://docs.google.com/feeds/default/private/full/document%3Adocument_id/acl

The %3A is critical as the following url (with %3A replaced by a colon) returns 
a 404 for us:

https://docs.google.com/feeds/default/private/full/document:document_id/acl

That automatic decoding from %3A to : happens within the internals of the 
GenericUrl class. 

As an attempt to work around this, I replaced the "%" with a "%25" with the 
hopes that GoogleUrl would properly escape the "%25" back to a "%" and all 
would be well:  

https://docs.google.com/feeds/default/private/full/document%253Adocument_id/acl

However, this only resulted in the GenericUrl building an unchanged, incorrect 
url:

https://docs.google.com/feeds/default/private/full/document%253Adocument_id/acl

Since the methods that encode and decode within GenericUrl are final/private, 
there does not appear to be a way to properly construct a url to access the 
Google Docs ACL Feed using the class. 

Original issue reported on code.google.com by [email protected] on 16 Aug 2011 at 3:11

downloaded content zero length without Logging

Version of google-http-java-client (e.g. 1.5.0-beta)?
1.5.0-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Android 2.2 emulator on Fedora 16
jdk1.6.0_27


Describe the problem.

With logging disabled,downloaded content has zero bytes.
With logging enabled, downloaded content is correct.

Code fragment to isolate fault.......
----------- code start -------------------
private void doDtest() {
 String url = "https://docs.google.com/feeds/download/documents/export/Export?id=12DquFymgKDTeIKkHa-OQuO5V-pHz-1v5EKAxaQPwQm0&exportFormat=html&format=html";
 byte[] content1 = da.fetchDocumentContent(url, "xls");
 System.out.println("===========1 "+content1.length);
 Logger.getLogger("com.google.api.client").setLevel(Level.INFO);
 Logger.getLogger("com.google.api.client.http").setLevel(Level.ALL);
 byte[] content2 = da.fetchDocumentContent(url, "xls");
 System.out.println("===========2 "+content2.length;
 Logger.getLogger("com.google.api.client").setLevel(Level.INFO);
 Logger.getLogger("com.google.api.client.http").setLevel(Level.OFF);
 byte[] content3 = da.fetchDocumentContent(url, "xls");
 System.out.println("===========3 "+content3.length;
}

byte[] da.fetchDocumentContent(String url, String type) {
 HttpRequest request = requestFactory.buildGetRequest(url);
 request.setDisableContentLogging(true);
 l("[DA733] fdc url=" + request.getUrl() + "  type=" + type);
 HttpResponse response = null;
 response = request401(request);
 response.setDisableContentLogging(true);
 InputStream is = response.getContent();
 content = new byte[is.available()];
 is.read(content);
 return content
}
------------ code end ---------------------

------------ log start --------------------
I/System.out( 4134): Tue Oct 18 21:32:31 GMT+00.00 2011)  [DA733] fdc 
url=https://docs.google.com/feeds/download/documents/export/Export?id=12DquFymgK
DTeIKkHa-OQuO5V-pHz-1v5EKAxaQPwQm0&exportFormat=xls&format=xls  type=xls
D/dalvikvm(   59): GC_EXTERNAL_ALLOC freed 16768 objects / 830328 bytes in 126ms
I/System.out( 4134): ===========1 0 
I/System.out( 4134): Tue Oct 18 21:32:32 GMT+00.00 2011)  [DA733] fdc 
url=https://docs.google.com/feeds/download/documents/export/Export?id=12DquFymgK
DTeIKkHa-OQuO5V-pHz-1v5EKAxaQPwQm0&exportFormat=xls&format=xls  type=xls
D/dalvikvm( 4134): GC_FOR_MALLOC freed 11184 objects / 571448 bytes in 58ms
I/System.out( 4134): ===========2 4096 
I/System.out( 4134): Tue Oct 18 21:32:33 GMT+00.00 2011)  [DA733] fdc 
url=https://docs.google.com/feeds/download/documents/export/Export?id=12DquFymgK
DTeIKkHa-OQuO5V-pHz-1v5EKAxaQPwQm0&exportFormat=xls&format=xls  type=xls
I/System.out( 4134): ===========3 0 
------------- log end -------------------------

How would you expect it to be fixed?

The results should be identical regardless of logging 

Original issue reported on code.google.com by [email protected] on 20 Oct 2011 at 2:49

Automatically follow redirects

External references, such as a standards document, or specification?

http://tools.ietf.org/html/rfc2616#section-10.3
http://tools.ietf.org/html/rfc2616#section-14.30

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?

All

Please describe the feature requested.

By default the http library should automatically follow redirects, as specified 
in the Location header for a 3xx response.  See HTTP specification above.  We 
should add a setFollowRedirects method to disable this functionality.

NOTE: we need to be careful about the HttpUnsuccessfulResponseHandler in this 
case.  One option is that we should only follow the redirect if handleResponse 
returns false.

Original issue reported on code.google.com by [email protected] on 12 Sep 2011 at 11:32

Allow users to provide custom HttpClient to ApacheHttpTransport

It is sometimes useful to wrap Apache's DefaultHttpClient with a wrapper for 
some app specific functionality.

Once such example is Android:
Android has such a wrapper that does several things such as:

* Auto URL substitution - To divert requests through a Proxy for example.
* curl debugging : printing curl commands that allow developers to execute 
requests on a desktop

As is, the ApacheHttpTransport hard codes a DefaultHttpClient in the ctro. It 
would be very helpful to be able to provide a user created HttpClient.

Original issue reported on code.google.com by [email protected] on 28 Sep 2011 at 8:55

Allow annotation to specify a value-converter in tandem with @Key

External references, such as a standards document, or specification?

None that I am aware of.

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All.

Please describe the feature requested.

// framework

/**
 * Specifies a conversion.
 */
interface Converter<T> {
   String toString(T obj);
   T valueOf(String value) throws ParseException;
}

/** 
 * Tell google-api-java-client to apply the specified conversion.
 */ 
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Convert {
   Class<? extends Converter> value();
   // this is better than abusing @Key
}



// application example

import java.awt.Color;

class ColorConverter implements Converter<Color> {
   // has parameterless default constructor

   @Override
   public String toString(Color obj) {
      // format
   }

   @Override
   public Color valueOf(String value) throws ParseException {
      // parse
   }
}

class Calendar {
 @Key("gCal:color")
 @Convert(ColorConverter.class)
 public Color color;
}




Design notes:
  The framework could inspect a Converter<T>'s method annotation to decide whether to invoke the method if the input is null.  This could spare Converter implementors from having to deal with null input.

  A framework-provided "abstract Class DefaultConverter implements Converter" could be useful.

  Parse errors should not stop reading input, but there probably needs to be a way to callback the caller of the parseAs() method.

  The use-case anticipated here doesn't need control over *collections* (eg. @Key("entry") List<Entry> entries;) ... this case can probably be excluded from the design of the Converter.

  This converter doesn't solve more annoying issues like when the <entry/> of a calendar event feed specialises the <gd:comments/> element from the Event kind such that the <gd:feedLink/> points to a feed containing <entry/>s of the Message kind, and shouldn't try to.

Original issue reported on code.google.com by [email protected] on 16 Aug 2011 at 2:47

Support for text-based protocol buffer format

External references, such as a standards document, or specification?

http://code.google.com/p/protobuf/

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All.

Please describe the feature requested.

Similar to the binary protocol buffer format support we are adding in Issue 4, 
we can also add support for a text-based protocol buffer format.  Typical 
content type is "text/x-protobuf", and we can use TextFormat for 
parsing/serialization.

Original issue reported on code.google.com by [email protected] on 1 Jun 2011 at 2:48

Detect Unicode encoding for GSON library

External references, such as a standards document, or specification?

http://blog.publicobject.com/2010/08/handling-byte-order-mark-in-java.html

copied here (in case that blog goes away):

  public Reader inputStreamToReader(InputStream in) throws IOException {
    in.mark(3);
    int byte1 = in.read();
    int byte2 = in.read();
    if (byte1 == 0xFF && byte2 == 0xFE) {
      return new InputStreamReader(in, "UTF-16LE");
    } else if (byte1 == 0xFF && byte2 == 0xFF) {
      return new InputStreamReader(in, "UTF-16BE");
    } else {
      int byte3 = in.read();
      if (byte1 == 0xEF && byte2 == 0xBB && byte3 == 0xBF) {
        return new InputStreamReader(in, "UTF-8");
      } else {
        in.reset();
        return new InputStreamReader(in);
      }
    }
  }

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All.

Please describe the feature requested.

Currently the GSON library implementation only supports UTF-8.  The algorithm 
above could potentially be used for supporting the other 3 Unicode encodings 
supported by the JSON specifications.

Original issue reported on code.google.com by [email protected] on 11 May 2011 at 6:05

NullPointerException when response has no content

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.5.3-beta

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

App Engine

Describe the problem.

We got the following user report:

I get the exception below though the operation succeeded (person got removed 
from circle). It seems because the response is empty, which is expected 
according to the docs. I.e., the client library should handle this case 
gracefully.

java.lang.NullPointerException
       at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106)
       at com.google.api.client.extensions.appengine.http.urlfetch.UrlFetchResponse.getContent(UrlFetchResponse.java:67)
       at com.google.api.client.http.HttpResponse.getContent(HttpResponse.java:211)
       at com.google.api.client.http.HttpResponse.ignore(HttpResponse.java:253)
       at com.google.api.services.plusone.Plusone$People$RemoveFromCircle.execute(Plusone.java:2559)

See:
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/urlf
etch/HTTPResponse.html#getContent()

How would you expect it to be fixed?

UrlFetchResponse.getContent() in this case should return null, not throw a NPE

Original issue reported on code.google.com by [email protected] on 26 Oct 2011 at 2:44

Support for HTTP services based on protocol buffers

External references, such as a standards document, or specification?

http://code.google.com/p/protobuf/

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

HttpProtocolBufferContent and HttpProtocolBufferTextContent would be used for 
sending protocol buffer Message of binary content type "application/x-protobuf" 
or text content type "text/x-protobuf" (respectively).

Similarly HttpProtocolBufferParser and HttpProtocolBufferTextParser would be 
used for parsing protobuf response from server.

Original issue reported on code.google.com by [email protected] on 11 May 2011 at 3:37

Should have a limit to the amount of content to log

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.6.0-beta

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

All, but especially limited memory 

Describe the problem.

When logging is enabled, we log the content of the HTTP request and HTTP 
response.  There is currently no limit to the size of content that we will log. 
 To implement this, the whole content is stored in memory as a String.  For 
large content, this will result in an OutOfMemoryException.

See:

http://code.google.com/p/google-http-java-client/source/browse/google-http-clien
t/src/main/java/com/google/api/client/http/LogContent.java

http://code.google.com/p/google-http-java-client/source/browse/google-http-clien
t/src/main/java/com/google/api/client/http/HttpResponse.java

How would you expect it to be fixed?

We should either set a hard-coded limit -- like 100KB -- or make it 
configurable by having a logging limit variable with a reasonable default, 
possibly allowing to set it to -1 to indicate no limit.

Original issue reported on code.google.com by [email protected] on 18 Oct 2011 at 2:20

Simplify Staging process with Nexus Maven Plugin?

External references, such as a standards document, or specification?

http://www.sonatype.com/books/nexus-book/reference/staging-sect-managing-plugin.
html

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

N/A

Please describe the feature requested.

This might simplify the process by making it possible to close and release the 
staged artifact from the command line rather than having to do it from the UI.

Original issue reported on code.google.com by [email protected] on 29 Jul 2011 at 11:40

CustomizeJsonParser needs work

External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

CustomizeJsonParser needs some improvements. context should now be a 
List<Object> instead of just an Object.  There are also other variables the 
methods should accept like "Type valueType" for the newInstance methods now 
that we support Java generics and other complex types.

Original issue reported on code.google.com by [email protected] on 7 Jun 2011 at 1:12

Add a static compile method to UriTemplate.java


Code review comment from Yaniv in http://codereview.appspot.com/5152047/:

Design question: should we use a similar design pattern for UriTemplate as for 
regular expressions in Java, i.e. Pattern?  The idea with Pattern is that you 
can pre-compile it and reuse to more efficiently match against multiple string 
inputs.  The parallel here is that UriTemplates will typically be reused often 
on multiple parameter inputs.  So it would be great to have a static 
compile(String template) method that returns a new compiled UriTemplate 
instance with an expand(Object parameters) method that performed the expansion. 
 We could still keep the existing expand(String template, Object parameters) 
method, but its implementation would simply be 
UriTemplate.compile(template).expand(parameters).

But given that this design pattern is just a performance optimization and a 
significant re-work of your implementation, I'm happy to just leave it with a 
TODO and/or a feature request on the public Issue tracker to do in the future.  
It is relatively low priority.

Original issue reported on code.google.com by [email protected] on 14 Oct 2011 at 4:59

Missing JavaDoc link

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.5.0-beta

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

All.

Describe the problem.

See for example:

http://javadoc.google-http-java-client.googlecode.com/hg/1.5.0-beta/com/google/a
pi/client/util/GenericData.html

click on Object and you get a broken page link to:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true

How would you expect it to be fixed?

It should instead point to:

http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html

Original issue reported on code.google.com by [email protected] on 22 Sep 2011 at 8:43

JsonFactory#toString() depends on default charset

Version of google-http-java-client (e.g. 1.5.0-beta)?
1.5.0-beta

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

Describe the problem.
Result of method com.google.api.client.json.JsonFactory#toString() depends on 
Java VM default charset. So multi-byte characters in model are serialized as 
invalid mark if default charset is not UTF-8 (e.g. App Engine production).

Example:
com.google.api.services.tasks.model.Tasks tasks = ...;  // model
String json = tasks.toString();  // GenericJson#toString() calls 
JsonFactory#toString()

This code will work if default charset is UTF-8, but not work correctly if 
US-ASCII.

How would you expect it to be fixed?
Use ByteArrayOutputStream#toString(charset) instead.

Patch:
http://code.google.com/p/google-http-java-client/source/browse/google-http-clien
t/src/main/java/com/google/api/client/json/JsonFactory.java
line 91
  public final String toString(Object item) {
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    try {
      JsonGenerator generator = createJsonGenerator(byteStream, JsonEncoding.UTF8);
      generator.serialize(item);
      generator.flush();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
-    return byteStream.toString();
+    try {
+      return byteStream.toString("UTF-8");
+    }
+    catch (UnsupportedEncodingException e) {
+      throw new RuntimeException(e);
+    }
  }

Original issue reported on code.google.com by [email protected] on 24 Aug 2011 at 12:33

HttpResponse.parseAsString() should respect charset Content-Type parameter

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.5.0-beta

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

All

Describe the problem.

HttpResponse.parseAsString() uses the platform's default charset when parsing 
the content, even if the Content-Type header looks like this:

Content-Type:  application/json; charset=UTF-8

Reference:
http://code.google.com/p/google-http-java-client/source/browse/google-http-clien
t/src/main/java/com/google/api/client/http/HttpResponse.java#420

How would you expect it to be fixed?

I would expect parseAsString() to read the charset parameter from the 
Content-Type header to determine the character set to use to parse.  Typically 
this will be UTF-8, which will typically be different from the platform's 
default encoding.

Original issue reported on code.google.com by [email protected] on 13 Oct 2011 at 2:17

Support for alternative "HTTP parser detector"

External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

Currently HttpRequest has a built-in map from content type string to 
HttpParser.  In HttpResponse.getParser(), it calls 
HttpRequest.getParser(contentType) which normalizes the content type (removes 
any parameters) and then returns the HttpParser mapped by the normalized 
content type.

This may not necessarily be the only possible useful algorithm.  This feature 
request attempts to abstract out the way the HttpParser is chosen.  For example:

public interface HttpParserDetector {
  HttpParser detect(HttpResponse response);
}

We could provide a simple implementation like this:

public class DefaultParserDetector implements HttpParserDetector {
  private final HttpParser parser;
  public DefaultParserDetector(HttpParser parser) {
    this.parser = parser;
  }
  public HttpParser detect(HttpResponse response) {
    return parser;
  }
}

As well as one that matches the existing behavior:

 public class ContentTypeParserDetector implements HttpParserDetector {
  /** Map from content type to HTTP parser. */
  private final Map<String, HttpParser> contentTypeToParserMap = new HashMap<String, HttpParser>();
...
}

Original issue reported on code.google.com by [email protected] on 7 Jun 2011 at 11:29

DateTime should be final [BACKWARDS INCOMPATIBLE]

External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

See Item 15 of Effective Java 2nd ed: in order to make a class immutable, you 
need to ensure that it cannot be extended.

Original issue reported on code.google.com by [email protected] on 7 Jun 2011 at 1:49

problem downloading files >= 2gb from google storage. Get connection timeout after file transferred

Version of google-http-java-client (e.g. 1.5.0-beta)?
1.6.0-beta-SNAPSHOT
latest from default branch

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

Describe the problem.
No issue with files less than 2 gb in size.  But for files equal or greater 
than 2gb on last read I would expect to receive a -1 to indicate EOF, but 
instead I get a socket timeout.

How would you expect it to be fixed?
-1 retrieved from read instead of socket timeout exception.

Original issue reported on code.google.com by [email protected] on 3 Oct 2011 at 12:54

Support CSV

External references, such as a standards document, or specification?

http://en.wikipedia.org/wiki/Comma-separated_values
http://code.google.com/apis/fusiontables/
http://opencsv.sourceforge.net/
http://stackoverflow.com/questions/101100/csv-api-for-java

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

Comma-separated values (CSV) is a common format with a fairly long history.  
The Google Fusion Tables API returns CSV in its response format.  Opencsv seems 
to be a popular choice, but we can evaluate others as well.

Original issue reported on code.google.com by [email protected] on 20 May 2011 at 12:13

javadocs for HttpRequestFactory use deprecated HttpRequest.headers field

Version of google-http-java-client (e.g. 1.5.0-beta)?

1.5.0-beta

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

All

Describe the problem.

JavaDocs for HttpRequestFactory in 1.5.0 
(http://javadoc.google-http-java-client.googlecode.com/hg/1.5.0-beta/com/google/
api/client/http/HttpRequestFactory.html) reference the now-deprecated 
HttpRequest.headers field in the example code:

  public static HttpRequestFactory createRequestFactory(HttpTransport transport) {
    return transport.createRequestFactory(new HttpRequestInitializer() {
      public void handle(HttpRequest request) {
        request.headers.authorization = "...";
      }
    });
  }

How would you expect it to be fixed?

Change the example to:

request.getHeaders().authorization = "...";

Thanks to [email protected] for reporting!

Original issue reported on code.google.com by [email protected] on 15 Aug 2011 at 3:27

Detect Unicode encoding for GSON library

External references, such as a standards document, or specification?

http://blog.publicobject.com/2010/08/handling-byte-order-mark-in-java.html

copied here (in case that blog goes away):

  public Reader inputStreamToReader(InputStream in) throws IOException {
    in.mark(3);
    int byte1 = in.read();
    int byte2 = in.read();
    if (byte1 == 0xFF && byte2 == 0xFE) {
      return new InputStreamReader(in, "UTF-16LE");
    } else if (byte1 == 0xFF && byte2 == 0xFF) {
      return new InputStreamReader(in, "UTF-16BE");
    } else {
      int byte3 = in.read();
      if (byte1 == 0xEF && byte2 == 0xBB && byte3 == 0xBF) {
        return new InputStreamReader(in, "UTF-8");
      } else {
        in.reset();
        return new InputStreamReader(in);
      }
    }
  }

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

Currently the GSON library implementation only supports UTF-8.  The algorithm 
above could potentially be used for supporting the other 3 Unicode encodings 
supported by the JSON specifications.

Original issue reported on code.google.com by [email protected] on 4 Jun 2011 at 4:12

  • Merged into: #6

Ability to parse a JSON HttpResult containing an Array of objects

External references, such as a standards document, or specification?

Discussion Thread 
http://groups.google.com/group/google-api-java-client/browse_thread/thread/73945
dc17855052e

Example API
http://dev.twitter.com/doc/get/users/search

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

Currently the api client cannot parse an HttpResponse formatted as a JSON array 
of objects.

ie: [{"prop1":"val1","prop2":"val2"},{"prop1":"val1","prop2":"val2"}] 

Attempting to parse using parseAs(class) generates an IllegalArgumentException:

Exception in thread "main" java.lang.IllegalArgumentException: START_ARRAY at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java: 
88) 

Note that parseAsString() does work properly but the call 
Feed resp = response.parseAs(Feed.class); 
Should properly parse and return a feed object.

[Copied from 
http://code.google.com/p/google-api-java-client/issues/detail?id=218]

Reported by [email protected], May 21 (41 hours ago)

Comment 1 by project member [email protected], Today (9 hours ago)
I'm not sure that  Feed resp = response.parseAs(Feed.class)  should be expected 
to work because Feed would be an object, and the response is really an array of 
objects.  I wouldn't mind a syntax like:
         List<Item> response = response.parseAs(Item.class);
We should be able to make that work, and would be the obvious thing if you had 
used parseAs() before. OTOH, I'm not looking at the code right now.  The use of 
templating may require a different name, so the signature might be   template 
List<T> parseAsArray( class T);

Comment 2 by project member [email protected], Today (7 hours ago)
An alternative is
  List<Item> items = new ArrayList<Item>();
  Status status =  response.parseInto(items);

This eliminates the need for a template method, so it may result in less code 
size.

Original issue reported on code.google.com by [email protected] on 23 May 2011 at 11:19

JsonHttpClient.buildHttpRequest should be able to handle different values of baseUrl and uriTemplate


Currently JsonHttpClient.buildHttpRequest has very strict requirements on what 
the baseUrl and uriTemplate can look like:
baseUrl must end with "/"
uriTemplate cannot start with "/".

JsonHttpClient.buildHttpRequest should be changed to handle baseUrl and 
uriTemplate regardless if they end with or start with "/".

Original issue reported on code.google.com by [email protected] on 21 Oct 2011 at 5:10

Make HttpRequestFactory non final

External references, such as a standards document, or specification?
-

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?
Android 2.3 with Google API

Please describe the feature requested.

Make the HttpRequestFactory non-final class to allow extensibility and mocking 
with unit test frameworks such as Mockito.

Original issue reported on code.google.com by [email protected] on 19 Oct 2011 at 10:46

Bug in parseAs when NetHttpTransport is used

public <T> T parseAs(Class<T> dataClass) throws IOException {
    HttpParser parser = getParser();
    if (parser == null) {
      InputStream content = getContent(); <-- !!!!!!!! THIS WON"T BE NULL FOR EMPTY RESPONSE WHEN NetHttpTransport is USED. WORKS FINE FOR ApacheHttpTransport !!!!!!!
      if (contentType == null) {
        if (content != null) {
          throw new IllegalArgumentException(
              "Missing Content-Type header in response: " + parseAsString());
        }
        return null;
      }
      throw new IllegalArgumentException("No parser defined for Content-Type: " + contentType);
    }
    return parser.parse(this, dataClass);
  }


Original issue reported on code.google.com by [email protected] on 24 Sep 2011 at 9:14

DailyMotion API command-line sample

Which API and version (e.g. Google Calendar Data API version 2)?

Dailymotion API

What format (e.g. JSON, XML)?

JSON

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

Java 6 command-line

External references, such as API reference guide?

http://www.dailymotion.com/doc/api/rest-api-reference.html#get-videos

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 15 Sep 2011 at 3:30

Key/Value Pair parser support for Really Simple Syndication (RSS)?

External references, such as a standards document, or specification?
http://en.wikipedia.org/wiki/RSS

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?
Any

Please describe the feature requested.
Would it be possible to extend the key/value pairing parser to support RSS? RSS 
holds a very closely related structure to Atom. The only variation is the lack 
of a default namespace.

Original issue reported on code.google.com by [email protected] on 10 Sep 2011 at 9:33

Pretty-printing JSON

External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?

All

Please describe the feature requested.

Currently JSON serialization is a compact form, which is not ideal for 
debugging or other human-consumption.  Would be nice to allow a way to 
serialize JSON in pretty-printed form for this purpose.  An example use case is 
to pretty-print the JSON error response from Google APIs.

Original issue reported on code.google.com by [email protected] on 1 Nov 2011 at 3:41

XPath support for @Key

External references, such as a standards document, or specification?

http://www.w3.org/TR/xpath/

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.3, or All)?

All

Please describe the feature requested.

http://code.google.com/p/google-api-java-client/issues/detail?id=225

Reported by [email protected], Jun 4, 2011

Not sure how feasible this is, but instead of supporting only this type of 
mapping:

@Key(atom:link)
public List<Link> links;

I would like to see syntax that would allow for something like this:

@Key(atom:link[@rel='next])
public Link nextLink;

Or, even better something like this:

@Key(atom:link[@rel='next']/@value)
public String nextLinkValue;

http://code.google.com/p/google-api-java-client/issues/detail?id=72

Reported by [email protected], Dec 6, 2010

The @Key("param") annotation does not support nested tags per Partial Response 
idioms.  For example: @Key("gf:symbol/@symbol") should return the symbol 
attribute from the symbol element within the element being parsed, without 
requiring the user to create a new class as an intermediary.  1.2.1-alpha fails 
to parse and returns null.  Support for nested elements would be of great help 
in parsing as some of the Google APIs nest rather deeply and it would be useful 
to be able to flatten the structure somewhat.  Another example is 
@Key("gf:positionData/gf:marketValue/gf:money/@amount" -- Does that really need 
three nested classes to parse?

Original issue reported on code.google.com by [email protected] on 4 Jun 2011 at 4:08

Asynchronous requests

Copied from previous project from:
http://code.google.com/p/google-api-java-client/issues/detail?id=151


Please describe the feature requested.

It would be nice to provide an executeAsync method in HttpRequest that started 
a new thread to execute the request and when it got the final response would 
call an implementation of an HttpAsyncCallback interface similar to the one in 
GWT:

http://google-web-toolkit.googlecode.com/svn/javadoc/2.2/com/google/gwt/user/cli
ent/rpc/AsyncCallback.html

Sample usage:

  public static void run(HttpRequest request) {
    request.executeAsync(new HttpAsyncCallback() {
      public void onSuccess(HttpResponse response) {
        if (response.isSuccessStatusCode) {
          // server sent a success response
        } else {
          // server sent an error response
        }
      }

       public void onFailure(Throwable caught) {
         // Convenient way to find out which exception was thrown.
         try {
           throw caught;
         } catch (IOException e) {
           // some networking problem?
         } catch (Throwable e) {
           // last resort -- a very unexpected exception
         }
       }
    });
  }

Comment 1 by [email protected], Mar 19, 2011

+1 on the feature, I think it would be nice to provide this.

A couple comments on the sample usage as it is:

1.) onSuccess() gives you a response, which you then have to check for whether 
or not it was actually a success? Maybe it should be called onResponse() if 
it's not actually going to be a sign of success.

2.) I would argue that re-throwing the Throwable and catching it to find out 
what it was is not very convenient. Try/catch blocks should not be a control 
flow mechanism, they should be an error handling mechanism.  It might be better 
to have instanceof check, but even that feels a little gross.

Also, for brevity, it might be nice to provide an abstract class, 
DefaultCallback, that implements onFailure() in a default way, so that 
developers don't have to write both branches for every request. This may be a 
recommendation for samples more than a recommendation for the library itself, 
since "the default way" might depend a lot on the environment, but either way I 
thought I'd mention it.

Also (also), for App Engine, since you can't spawn threads, you could use an 
asynchronous urlfetch as described here: 
http://ikaisays.com/2010/06/29/using-asynchronous-urlfetch-on-java-app-engine/

Comment 2 by project member [email protected], Mar 19, 2011

Thanks for the feedback!

I agree with the onResponse() name.  That makes more sense.

The most interesting question is what to do about this for App Engine.  
executeAsync as outlined here just wouldn't work with fetchAsync since that 
uses a Future.  I suppose we could still have executeAsync but throw an 
exception on App Engine.

Alternatively, we could use a Future-style interface like App Engine has, e.g.:

public class HttpRequest {
  public Future fetchAsync();
}

and provide a way to override the behavior in the HttpTransport such that 
UrlFetchTransport would use URLFetchService.fetchAsync().

Comment 3 by project member [email protected], Mar 20, 2011

while we're doing this reconfiguration, maybe it's time to think about streaming
as well. The async callbacks would be

OnFailure - called immediately if you get an error return
OnHeaders(HttpResponse response) - called with all the header data
OnData(HttpRespose response, byte [] data, length) - on each successive chunk 
of data.
OnSuccess(HttpResposne response) - when we are finally done.

An app could get away with just OnFailure and OnSuccess, but an app that
did streaming responses could start parsing the JSON as it arrives.

-tony

Original issue reported on code.google.com by [email protected] on 11 May 2011 at 3:33

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.