{"action":"created","issue":{"url":"https://api.github.com/repos/relayrides/pushy/issues/228","labels_url":"https://api.github.com/repos/relayrides/pushy/issues/228/labels{/name}","comments_url":"https://api.github.com/repos/relayrides/pushy/issues/228/comments","events_url":"https://api.github.com/repos/relayrides/pushy/issues/228/events","html_url":"https://github.com/relayrides/pushy/issues/228","id":129374211,"number":228,"title":"NPE at ApnsClient.operationComplete()","user":{"login":"neyron91","id":5107306,"avatar_url":"https://avatars.githubusercontent.com/u/5107306?v=3","gravatar_id":"","url":"https://api.github.com/users/neyron91","html_url":"https://github.com/neyron91","followers_url":"https://api.github.com/users/neyron91/followers","following_url":"https://api.github.com/users/neyron91/following{/other_user}","gists_url":"https://api.github.com/users/neyron91/gists{/gist_id}","starred_url":"https://api.github.com/users/neyron91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neyron91/subscriptions","organizations_url":"https://api.github.com/users/neyron91/orgs","repos_url":"https://api.github.com/users/neyron91/repos","events_url":"https://api.github.com/users/neyron91/events{/privacy}","received_events_url":"https://api.github.com/users/neyron91/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/relayrides/pushy/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/relayrides/pushy/milestones/11","html_url":"https://github.com/relayrides/pushy/milestones/v0.5.2","labels_url":"https://api.github.com/repos/relayrides/pushy/milestones/11/labels","id":1552914,"number":11,"title":"v0.5.2","description":"","creator":{"login":"jchambers","id":31352,"avatar_url":"https://avatars.githubusercontent.com/u/31352?v=3","gravatar_id":"","url":"https://api.github.com/users/jchambers","html_url":"https://github.com/jchambers","followers_url":"https://api.github.com/users/jchambers/followers","following_url":"https://api.github.com/users/jchambers/following{/other_user}","gists_url":"https://api.github.com/users/jchambers/gists{/gist_id}","starred_url":"https://api.github.com/users/jchambers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jchambers/subscriptions","organizations_url":"https://api.github.com/users/jchambers/orgs","repos_url":"https://api.github.com/users/jchambers/repos","events_url":"https://api.github.com/users/jchambers/events{/privacy}","received_events_url":"https://api.github.com/users/jchambers/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2016-01-30T17:07:21Z","updated_at":"2016-01-30T17:07:29Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-01-28T08:03:48Z","updated_at":"2016-01-30T17:09:45Z","closed_at":"2016-01-30T17:07:04Z","body":"Hi! I've got an exceptions sometimes when I tried to connect to the APNs and it wasn't available:\r\n```\r\n[nioEventLoopGroup-2-1] INFO com.relayrides.pushy.apns.ApnsClient - Failed to connect.\r\njava.lang.IllegalStateException: Channel closed before HTTP/2 preface completed.\r\n\tat com.relayrides.pushy.apns.ApnsClient$3.operationComplete(ApnsClient.java:444)\r\n\tat com.relayrides.pushy.apns.ApnsClient$3.operationComplete(ApnsClient.java:438)\r\n\tat io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680)\r\n\tat io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:567)\r\n\tat io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:406)\r\n\tat io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82)\r\n\tat io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:1021)\r\n\tat io.netty.channel.AbstractChannel$AbstractUnsafe.doClose0(AbstractChannel.java:665)\r\n\tat io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:643)\r\n\tat io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:587)\r\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.close(DefaultChannelPipeline.java:1218)\r\n\tat io.netty.channel.ChannelHandlerInvokerUtil.invokeCloseNow(ChannelHandlerInvokerUtil.java:133)\r\n\tat io.netty.channel.DefaultChannelHandlerInvoker$13.run(DefaultChannelHandlerInvoker.java:291)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)\r\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:356)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)\r\n\tat io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n```\r\n```\r\n[nioEventLoopGroup-2-1] WARN io.netty.util.concurrent.DefaultPromise - An exception was thrown by com.relayrides.pushy.apns.ApnsClient$2.operationComplete()\r\njava.lang.NullPointerException\r\n\tat com.relayrides.pushy.apns.ApnsClient$2.operationComplete(ApnsClient.java:433)\r\n\tat com.relayrides.pushy.apns.ApnsClient$2.operationComplete(ApnsClient.java:427)\r\n\tat io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680)\r\n\tat io.netty.util.concurrent.DefaultPromise$3.run(DefaultPromise.java:664)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)\r\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:356)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)\r\n\tat io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n```\r\n\r\nis it a bug?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/relayrides/pushy/issues/comments/177249294","html_url":"https://github.com/relayrides/pushy/issues/228#issuecomment-177249294","issue_url":"https://api.github.com/repos/relayrides/pushy/issues/228","id":177249294,"user":{"login":"jchambers","id":31352,"avatar_url":"https://avatars.githubusercontent.com/u/31352?v=3","gravatar_id":"","url":"https://api.github.com/users/jchambers","html_url":"https://github.com/jchambers","followers_url":"https://api.github.com/users/jchambers/followers","following_url":"https://api.github.com/users/jchambers/following{/other_user}","gists_url":"https://api.github.com/users/jchambers/gists{/gist_id}","starred_url":"https://api.github.com/users/jchambers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jchambers/subscriptions","organizations_url":"https://api.github.com/users/jchambers/orgs","repos_url":"https://api.github.com/users/jchambers/repos","events_url":"https://api.github.com/users/jchambers/events{/privacy}","received_events_url":"https://api.github.com/users/jchambers/received_events","type":"User","site_admin":false},"created_at":"2016-01-30T17:09:45Z","updated_at":"2016-01-30T17:09:45Z","body":"It looks like the problem was that we had two separate listeners that could detection failure; in some cases, the \"channel has closed\" listener would fire before the \"connection attempt failed\" listener. The former would clear the \"connection attempt is done\" promise, and then the latter would try to mark that (now-`null`) promise as failed.\r\n\r\nRather than trying to find a way to force those things to happen in order, we can just eliminate the \"connection attempt failed\" listener since the \"connection closed\" listener will fire in all cases when the connection attempt would have failed."}}