Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using batch with google-calendar api causes NullPointerException #579

Closed
wonderfly opened this issue Jan 10, 2015 · 3 comments
Closed

Using batch with google-calendar api causes NullPointerException #579

wonderfly opened this issue Jan 10, 2015 · 3 comments
Assignees
Labels
imported priority: p2 Moderately-important priority. Fix may not be included in next release. status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@wonderfly
Copy link
Contributor

From Marian.F...@googlemail.com on July 18, 2012 07:16:45

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... https://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: http://code.google.com/p/google-api-java-client/issues/detail?id=564

@wonderfly wonderfly added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. imported priority: p2 Moderately-important priority. Fix may not be included in next release. 1 star labels Jan 10, 2015
@wonderfly wonderfly self-assigned this Jan 10, 2015
@wonderfly
Copy link
Contributor Author

From rmis...@google.com on July 30, 2012 11:59:03

Status: Accepted
Labels: Milestone-Version1.11.0

@wonderfly
Copy link
Contributor Author

From rmis...@google.com on July 31, 2012 07:08:25

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.

Status: ByDesign

@wonderfly
Copy link
Contributor Author

From rmis...@google.com on July 31, 2012 07:09:40

WontFix is probably more appropriate here.

Status: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported priority: p2 Moderately-important priority. Fix may not be included in next release. status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant