windy0605 / javapns

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

Notifications pushed via PushQueue with expired token are marked as successful #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

1. Initialize a PushQueue
2. Schedule a payload with a 64 byte invalid token via PushQueue.add()
3. Check PushQueue.getPushedNotifications()

Expected Result: 
the corresponding PushedNotification object would have isSuccessful() = false
as well as it would have a proper non-null Exception when calling 
getException() method

Actual Result:
the corresponding PushedNotification object is marked as successful and 
getException() returns null

NOTE: When calling Push.payload() method with exact same token as in repro 
steps the resulting PushedNotification object has the correct behavior (i.e. 
isSuccessful() = false getException() != null)

What version of the product are you using? On what operating system?
2.2 MAC OSX

Original issue reported on code.google.com by dmitry.a...@gmail.com on 7 May 2013 at 4:29

GoogleCodeExporter commented 9 years ago
How much time do you wait between adding the payload to the queue, and invoking 
getPushedNotifications?

Since a push queue runs asynchronously, the results would not be available 
immediately after adding a payload to the queue.  If you need to examine 
results, you should either wait for the queue to do its work asynchronously, or 
use a Push.payloads method.

Original comment by sype...@gmail.com on 8 May 2013 at 8:56

GoogleCodeExporter commented 9 years ago
I am not expecting results immediately. Instead I have a thread that runs every 
2sec. and does the following

1. a.PushedNotifications sentNotifications = queue.getPushedNotifications()
   b.for every PushedNotification in queue.getPushedNotifications()

2. queue.clearPushedNotifications() 

My test schedules 10 push notifications (5 with VALID token and 5 with INVALID 
token. (64 byte long so I don't get InvalidTokenException)) 

Here is the code snippet (NOTE that I don't clear the queue for bug 
demonstration purposes):

private void runQueueResultListener()
    {
        final Runnable queueResultListener = new Runnable() 
        {

            @Override
            public void run() 
            {
                while(true)
                {
                    System.out.println("----------------------");
                    int i = 0;
                    for(PushedNotification pn : queue.getPushedNotifications())
                    {
                        System.out.println(i + "." + pn.isTransmissionCompleted() + pn.isSuccessful());
                        i++;
                    }

                    try 
                    {
                        Thread.sleep(2000);
                    }
                    catch(Throwable t)
                    {
                        t.printStackTrace();
                    }
                }

            }
        };

        new Thread(queueResultListener).start();
    }

Now. At any point I get a list of 10 PushedNotification objects. Every one has 
isTransmissionComplete() = true and isSuccessful() - true no matter how long I 
run this code

Original comment by dmitry.a...@gmail.com on 8 May 2013 at 9:43