Phoenixasuga / google-api-java-client

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

Using batch with google-calendar api causes NullPointerException #564

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client: 
google-api-client-1.10.3-beta

Java environment: JEE6

Describe the problem.
Using batch with google-calendar api causes NullPointerException :

public class Constants {

     /** Global instance of the HTTP transport. */
      public static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

      /** Global instance of the JSON factory. */
      public static final JsonFactory JSON_FACTORY = new JacksonFactory();
    //...
}
@Stateless
public class GetCalendarList {

    public List<CalendarListEntry> getCalendarList() {  
    //...

com.google.api.services.calendar.Calendar calendarService = 
com.google.api.services.calendar.Calendar
                        .builder(Constants.HTTP_TRANSPORT, Constants.JSON_FACTORY).setHttpRequestInitializer(credential).build();

                CalendarList feed = null;
                Events events = null;

            feed = calendarService.calendarList().list().execute(); 

            List<CalendarListEntry> calendarList = feed.getItems(); 
            final List<Events> eventsList = new LinkedList<Events>();   

            BatchRequest batch = calendarService.batch();

            JsonBatchCallback<Events> callback = new JsonBatchCallback<Events>() {

                public void onSuccess(Events content, GoogleHeaders responseHeaders) {
                    System.out.println("Success");
                    eventsList.add(content);
                }

                public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
                System.out.println(e.getMessage());
                }
            };

            for(CalendarListEntry e : calendarList){
                    System.out.println(e.getSummary()+" id:"+e.getId());
                    calendarService.events().list(e.getId()).queue(batch, callback);
            }

            batch.execute(); //(GetCalendarList.java:123)

        //...
        }
    }

Everything is working fine except "batch.execute(); 
//(GetCalendarList.java:123)" causing:

java.lang.NullPointerException
    at com.google.api.client.googleapis.batch.BatchUnparsedResponse.getParsedDataClass(BatchUnparsedResponse.java:202)
    at com.google.api.client.googleapis.batch.BatchUnparsedResponse.parseAndCallback(BatchUnparsedResponse.java:186)
    at com.google.api.client.googleapis.batch.BatchUnparsedResponse.parseNextResponse(BatchUnparsedResponse.java:136)
    at com.google.api.client.googleapis.batch.BatchRequest.execute(BatchRequest.java:222)
    at ba.test.calendercommunication.GetCalendarList.getCalendarList(GetCalendarList.java:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

...

How would you expect it to be fixed?

Perhaps error in this class? Anything wrong with using this code in JEE? I have 
no idea...

http://code.google.com/p/google-api-java-client/source/browse/google-api-client/
src/main/java/com/google/api/client/googleapis/batch/BatchUnparsedResponse.java?
r=e5756266c20aa39b5ac8623e0f36685b09486cd4

Original issue reported on code.google.com by Marian.F...@googlemail.com on 18 Jul 2012 at 2:16

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 30 Jul 2012 at 6:59

GoogleCodeExporter commented 9 years ago
This is an interesting bug. I could not reproduce it using calendar ids of the 
form "xyz@gmail.com" but then I tried one with that looked like 
"en.usa#holiday@group.v.calendar.google.com" and the response failed with:
HTTP/1.1 404 Not Found
with content "Not Found".

And then I found an open bug in the stack (opened 5 days ago) where the server 
is apparently double escaping.

Closing this bug as ByDesign because the client library code is working, the 
bug on the server will hopefully be fixed soon.

Original comment by rmis...@google.com on 31 Jul 2012 at 2:08

GoogleCodeExporter commented 9 years ago
WontFix is probably more appropriate here.

Original comment by rmis...@google.com on 31 Jul 2012 at 2:09