mwkirk / javapns

Test import of svn javapns repo from Google Code
3 stars 0 forks source link

NotificationThreads.makeGroups(...) should throw a better exception when an empty list is provided by users #116

Closed mwkirk closed 11 years ago

mwkirk commented 11 years ago

Original author: rcha...@devosinc.com (April 13, 2012 01:30:56)

What steps will reproduce the problem?

  1. Execute the following sample program:

public static void main(String[] args) { PushNotificationPayload payload = PushNotificationPayload.alert("test notification"); List<String> devices = new List<String>(); // empty list of devices int threads = 30; List<PushedNotification> notifications = Push.payload(payload, "keystore.p12", "password", false, threads, devices); }

What is the expected output? What do you see instead? Expected output: empty list of PushedNotifications (the same as when you invoke Push.payload(...) without the threads parameter). (Provided the keystore and password are valid, of course) What I see instead: the call to Push.payload hangs and never returns.

What version of the product are you using? On what operating system? Version 2.2 of the library, on MacOS X 10.7 and Linux (RedHat)

Please provide any additional information below. It's an easy to avoid error (just check if the device list is empty before invoking Push.payload), but I thought it'd be useful for you to know anyway.

Original issue: http://code.google.com/p/javapns/issues/detail?id=116

mwkirk commented 11 years ago

From sype...@gmail.com on April 13, 2012 02:17:05 I am unable to reproduce the problem with the latest build... Whenever I try to call that payload method with an empty devices list, I get "java.lang.ArithmeticException: / by zero", which seems appropriate.

Could you please try again with the latest build from the trunk?

If the issue still occurs, please provide a working sample code (the code you provided doesn't compile because of the invalid new List() construction, so I am assuming this is not the exact code you used), and include a stack trace dump when the code hangs.

Thank you!

mwkirk commented 11 years ago

From rcha...@devosinc.com on April 13, 2012 23:27:08 Sorry, my bad. I'm attaching an example source file and a stack trace dump. I'll download the latest build from the trunk later and let you know the results.

mwkirk commented 11 years ago

From rcha...@devosinc.com on April 13, 2012 23:49:49 I ran the same sample code with version 2.3 alpha 4 (downloaded from trunk) and I got an java.lang.ArithmeticException:

java.lang.ArithmeticException: / by zero at javapns.notification.transmission.NotificationThreads.makeGroups(NotificationThreads.java:214) at javapns.notification.transmission.NotificationThreads.(NotificationThreads.java:44) at javapns.Push.payload(Push.java:210) at com.notificador.SimplePush.main(SimplePush.java:17)

Hope this helps :)

mwkirk commented 11 years ago

From sype...@gmail.com on April 14, 2012 18:08:52 Since the latest build does throw an exception as expected (does not hang), I'm lowering the priority on this issue, which I believe turns out to be a request for throwing a more self-explanatory exception instead of that generic ArithmeticException :)

mwkirk commented 11 years ago

From sype...@gmail.com on April 24, 2012 03:19:02 Requested enhancement included in r363, which nows throws a proper IllegalArgumentException("Device list is empty, resulting in no threads being created.").