jungseung / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 reported on code.google.com by rcha...@devosinc.com on 13 Apr 2012 at 1:30

GoogleCodeExporter commented 8 years ago
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!

Original comment by sype...@gmail.com on 13 Apr 2012 at 2:17

GoogleCodeExporter commented 8 years ago
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.

Original comment by rcha...@devosinc.com on 13 Apr 2012 at 11:27

Attachments:

GoogleCodeExporter commented 8 years ago
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.<init>(NotificationThreads.java:44)
    at javapns.Push.payload(Push.java:210)
    at com.notificador.SimplePush.main(SimplePush.java:17)

Hope this helps :)

Original comment by rcha...@devosinc.com on 13 Apr 2012 at 11:49

GoogleCodeExporter commented 8 years ago
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 :)  

Original comment by sype...@gmail.com on 14 Apr 2012 at 6:08

GoogleCodeExporter commented 8 years ago
Requested enhancement included in r363, which nows throws a proper 
IllegalArgumentException("Device list is empty, resulting in no threads being 
created.").

Original comment by sype...@gmail.com on 24 Apr 2012 at 3:19