{"action":"created","issue":{"url":"https://api.github.com/repos/cloudfoundry/cf-java-client/issues/578","repository_url":"https://api.github.com/repos/cloudfoundry/cf-java-client","labels_url":"https://api.github.com/repos/cloudfoundry/cf-java-client/issues/578/labels{/name}","comments_url":"https://api.github.com/repos/cloudfoundry/cf-java-client/issues/578/comments","events_url":"https://api.github.com/repos/cloudfoundry/cf-java-client/issues/578/events","html_url":"https://github.com/cloudfoundry/cf-java-client/issues/578","id":189882974,"number":578,"title":"`cloudFoundryOperations.applications().getEvents()` errors out with some events","user":{"login":"zilkey","id":2451,"avatar_url":"https://avatars.githubusercontent.com/u/2451?v=3","gravatar_id":"","url":"https://api.github.com/users/zilkey","html_url":"https://github.com/zilkey","followers_url":"https://api.github.com/users/zilkey/followers","following_url":"https://api.github.com/users/zilkey/following{/other_user}","gists_url":"https://api.github.com/users/zilkey/gists{/gist_id}","starred_url":"https://api.github.com/users/zilkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zilkey/subscriptions","organizations_url":"https://api.github.com/users/zilkey/orgs","repos_url":"https://api.github.com/users/zilkey/repos","events_url":"https://api.github.com/users/zilkey/events{/privacy}","received_events_url":"https://api.github.com/users/zilkey/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-16T23:28:14Z","updated_at":"2016-11-22T14:58:44Z","closed_at":"2016-11-22T14:55:10Z","body":"It appears that `cloudFoundryOperations.applications().getEvents()` errors out when encountering certain event types.\r\n\r\nFrom what I can gather, events of type `audit.app.map-route` or `audit.app.create` cause the `getEvents()` call to error out.\r\n\r\nThe code that causes the error:\r\n\r\n```java\r\ncloudFoundryOperations\r\n                    .applications()\r\n                    .getEvents(GetApplicationEventsRequest\r\n                            .builder()\r\n                            .name(applicationName)\r\n                            .maxNumberOfEvents(4)\r\n                            .build())\r\n                    .collectList()\r\n                    .block();\r\n```\r\n\r\n> NOTE: I'm using the `.block()` just to make the demo easier, but it appears to work the same in the non-blocking version.\r\n\r\n## Expected behavior\r\n\r\nI expected the code to print out all of the events with no errors.\r\n\r\n## Actual behavior\r\n\r\nGot a `java.lang.NullPointerException`\r\n\r\n## Steps to reproduce\r\n\r\nI built a simple command-line app to demonstrate this.  It shows that getting certain events works, but not other events.\r\n\r\n- Deploy a simple app to cloud foundry (I just downloaded a web app from start.spring.io for this test)\r\n- Ensure that from the CLI the event log shows these events:\r\n\r\n  ```\r\n  Getting events for app events-test in org Galvanize Full Stack / space development as jeff@example.com...\r\n\r\n  time                          event                 actor                description\r\n  2016-11-16T15:05:16.00-0700   audit.app.update      jeff@example.com   state: STARTED\r\n  2016-11-16T15:05:05.00-0700   audit.app.update      jeff@example.com\r\n  2016-11-16T15:05:05.00-0700   audit.app.map-route   jeff@example.com\r\n  2016-11-16T15:05:03.00-0700   audit.app.create      jeff@example.com   instances: 1, state: STOPPED, environment_json: PRIVATE DATA HIDDEN\r\n  ```\r\n- Download https://github.com/zilkey/cloud-foundry-api-events-bug\r\n- Run it with:\r\n\r\n  ```\r\n  ./gradlew build && java -jar build/libs/cf-demo-0.0.1-SNAPSHOT.jar spring\r\n    api.run.pivotal.io \"Your organization\" your-space user@example.com abc-someapikey-zyx your-app-name\r\n  ```\r\n- You should see a null pointer exception like so:\r\n\r\n  ```\r\n  Total time: 1.415 secs\r\n\r\n    .   ____          _            __ _ _\r\n   /\\\\ / ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\r\n  ( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\r\n   \\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\r\n    '  |____| .__|_| |_|_| |_\\__, | / / / /\r\n   =========|_|==============|___/=/_/_/_/\r\n   :: Spring Boot ::        (v1.4.2.RELEASE)\r\n\r\n  2016-11-16 15:43:46.817  INFO 53028 --- [           main] com.acme.CfDemoApplication               : Starting CfDemoApplication on Jeff-Dean.local with PID 53028 (/Users/galvanize/Downloads/cf-demo/build/libs/cf-demo-0.0.1-SNAPSHOT.jar started by galvanize in /Users/galvanize/Downloads/cf-demo)\r\n  2016-11-16 15:43:46.820  INFO 53028 --- [           main] com.acme.CfDemoApplication               : No active profile set, falling back to default profiles: default\r\n  2016-11-16 15:43:46.876  INFO 53028 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@28c97a5: startup date [Wed Nov 16 15:43:46 MST 2016]; root of context hierarchy\r\n  2016-11-16 15:43:47.642  INFO 53028 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup\r\n  Getting 1 events\r\n    ApplicationEvent{actor=jeff@galvanize.com, description=state: STARTED, event=audit.app.update, id=f5e42610-dfa0-40b6-9de6-277edfd903d3, time=Wed Nov 16 15:05:16 MST 2016}\r\n  Getting 2 events\r\n    ApplicationEvent{actor=jeff@galvanize.com, description=state: STARTED, event=audit.app.update, id=f5e42610-dfa0-40b6-9de6-277edfd903d3, time=Wed Nov 16 15:05:16 MST 2016}\r\n    ApplicationEvent{actor=jeff@galvanize.com, description=, event=audit.app.update, id=3d5474db-2139-408d-a976-dcddcf9e7cab, time=Wed Nov 16 15:05:05 MST 2016}\r\n  Getting 3 events\r\n  2016-11-16 15:43:54.001  INFO 53028 --- [           main] utoConfigurationReportLoggingInitializer :\r\n\r\n  Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.\r\n  2016-11-16 15:43:54.009 ERROR 53028 --- [           main] o.s.boot.SpringApplication               : Application startup failed\r\n\r\n  java.lang.IllegalStateException: Failed to execute CommandLineRunner\r\n  \tat org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]\r\n  \tat org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]\r\n  \tat org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]\r\n  \tat org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]\r\n  \tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]\r\n  \tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]\r\n  \tat com.acme.CfDemoApplication.main(CfDemoApplication.java:30) [classes!/:na]\r\n  \tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05]\r\n  \tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_05]\r\n  \tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_05]\r\n  \tat java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_05]\r\n  \tat org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [cf-demo-0.0.1-SNAPSHOT.jar:na]\r\n  \tat org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [cf-demo-0.0.1-SNAPSHOT.jar:na]\r\n  \tat org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [cf-demo-0.0.1-SNAPSHOT.jar:na]\r\n  \tat org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [cf-demo-0.0.1-SNAPSHOT.jar:na]\r\n  Caused by: java.lang.NullPointerException: null\r\n  \tat org.cloudfoundry.operations.applications.DefaultApplications.getMetadataRequest(DefaultApplications.java:701) ~[cloudfoundry-operations-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]\r\n  \tat org.cloudfoundry.operations.applications.DefaultApplications.convertToApplicationEvent(DefaultApplications.java:509) ~[cloudfoundry-operations-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]\r\n  \tat org.cloudfoundry.operations.applications.DefaultApplications$$Lambda$79/1615056168.apply(Unknown Source) ~[na:na]\r\n  \tat reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:109) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.MonoFlatMap$FlattenSubscriber$InnerSubscriber.onNext(MonoFlatMap.java:194) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxTake$TakeSubscriber.onNext(FluxTake.java:136) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:661) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:541) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:1072) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:95) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:59) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:385) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.MonoFlatMap$FlattenSubscriber$InnerSubscriber.onNext(MonoFlatMap.java:194) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drainAsync(FluxFlattenIterable.java:358) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drain(FluxFlattenIterable.java:587) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.onNext(FluxFlattenIterable.java:216) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxBuffer$BufferExactSubscriber.onComplete(FluxBuffer.java:179) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onComplete(FluxConcatArray.java:177) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxConcatArray.subscribe(FluxConcatArray.java:96) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxBuffer.subscribe(FluxBuffer.java:74) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFlattenIterable.subscribe(FluxFlattenIterable.java:101) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.MonoFlatMap$FlattenSubscriber.onNext(MonoFlatMap.java:157) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxResume$ResumeSubscriber.onNext(FluxResume.java:74) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:164) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:126) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:892) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.MonoThenApply$MonoThenApplyManager$SecondSubscriber.onNext(MonoThenApply.java:201) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxUsing$UsingFuseableSubscriber.onNext(FluxUsing.java:314) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onNext(FluxFilterFuseable.java:108) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:368) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:892) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.MonoReduce$ReduceSubscriber.onComplete(MonoReduce.java:149) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.onComplete(FluxSubscribeOn.java:160) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.ipc.netty.common.NettyChannelHandler$InboundSink.drain(NettyChannelHandler.java:696) ~[reactor-netty-0.5.1.RELEASE.jar!/:na]\r\n  \tat reactor.ipc.netty.common.NettyChannelHandler$InboundSink.request(NettyChannelHandler.java:772) ~[reactor-netty-0.5.1.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.requestUpstream(FluxSubscribeOn.java:136) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.onSubscribe(FluxSubscribeOn.java:129) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.ipc.netty.common.NettyChannelHandler.subscribe(NettyChannelHandler.java:543) ~[reactor-netty-0.5.1.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxSource.subscribe(FluxSource.java:59) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.publisher.FluxSubscribeOn$SourceSubscribeTask.run(FluxSubscribeOn.java:231) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat reactor.core.scheduler.ExecutorScheduler$ExecutorTrackedRunnable.run(ExecutorScheduler.java:136) ~[reactor-core-3.0.2.RELEASE.jar!/:na]\r\n  \tat io.netty.util.concurrent.SingleThreadEventExecutor.safeExecute(SingleThreadEventExecutor.java:451) ~[netty-all-4.1.3.Final.jar!/:4.1.3.Final]\r\n  \tat io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:418) ~[netty-all-4.1.3.Final.jar!/:4.1.3.Final]\r\n  \tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:401) ~[netty-all-4.1.3.Final.jar!/:4.1.3.Final]\r\n  \tat io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877) ~[netty-all-4.1.3.Final.jar!/:4.1.3.Final]\r\n  \tat java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_05]\r\n\r\n  2016-11-16 15:43:54.012  INFO 53028 --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@28c97a5: startup date [Wed Nov 16 15:43:46 MST 2016]; root of context hierarchy\r\n  2016-11-16 15:43:54.012  INFO 53028 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown\r\n  ➜  cf-demo git:(master) ✗\r\n  ```\r\n\r\nAm I missing something here or is this a bug?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/cloudfoundry/cf-java-client/issues/comments/262262680","html_url":"https://github.com/cloudfoundry/cf-java-client/issues/578#issuecomment-262262680","issue_url":"https://api.github.com/repos/cloudfoundry/cf-java-client/issues/578","id":262262680,"user":{"login":"twoseat","id":3470048,"avatar_url":"https://avatars.githubusercontent.com/u/3470048?v=3","gravatar_id":"","url":"https://api.github.com/users/twoseat","html_url":"https://github.com/twoseat","followers_url":"https://api.github.com/users/twoseat/followers","following_url":"https://api.github.com/users/twoseat/following{/other_user}","gists_url":"https://api.github.com/users/twoseat/gists{/gist_id}","starred_url":"https://api.github.com/users/twoseat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twoseat/subscriptions","organizations_url":"https://api.github.com/users/twoseat/orgs","repos_url":"https://api.github.com/users/twoseat/repos","events_url":"https://api.github.com/users/twoseat/events{/privacy}","received_events_url":"https://api.github.com/users/twoseat/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T14:58:44Z","updated_at":"2016-11-22T14:58:44Z","body":"Thanks again for the report @zilkey - it turned out we were making an ill-founded assumption about some of the data coming out of the app events interface. That's been fixed, and as soon as we get a clean build (we're having some issues with a CI machine at the moment so it may take a while) you should be able to pick the fix up in a build snapshot. Let me know if you see any problems with that!"}}
{"actor":{"display_login":"twoseat"}}