google / gcm

Google Cloud Messaging - client libraries and sample implementations
https://developers.google.com/cloud-messaging
Apache License 2.0
824 stars 515 forks source link

200 NotRegistered throws IOException #235

Open nicdutil opened 7 years ago

nicdutil commented 7 years ago

When a 200 NotRegistered is sent back, the Sender.java code throws at line 222 when attempting to parse the response. This is when attempting to send a notification using a notification key that no longer exists on the gcm side.

Error parsing JSON response (): Unexpected token END OF FILE at position 0. at org.json.simple.parser.JSONParser.parse(Unknown Source) [json-simple-1.1.jar:] at org.json.simple.parser.JSONParser.parse(Unknown Source) [json-simple-1.1.jar:] at org.json.simple.parser.JSONParser.parse(Unknown Source) [json-simple-1.1.jar:] at com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:222) [gcm-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT] at com.google.android.gcm.server.Sender.send(Sender.java:182) [gcm-server-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]

java.io.IOException: Error parsing JSON response ():Unexpected token END OF FILE at position 0.

It would be nice to handle this case in the Sender code so I can remove the notification key and associated tokens from my db .