Closed mwkirk closed 11 years ago
From sype...@gmail.com on January 19, 2012 14:57:43 The capacity argument you see there corresponds to the Vector's initial capacity (see java.util.Vector's javadoc). It is not related to the maxRetained feature.
From ericpr...@gmail.com on January 19, 2012 15:31:24 Ok, but my concern is in the following code:
@Override public PushedNotifications getPushedNotifications() { int capacity = 0; for (NotificationThread thread : threads) capacity += thread.getPushedNotifications().size(); PushedNotifications all = new PushedNotifications(capacity); for (NotificationThread thread : threads) all.addAll(thread.getPushedNotifications()); return all; }
you compute the capacity of the array but you don't call the setMaxRetained capacity. When you call addAll(), it will retain only the last 1000 entries (see prepareAdd()).
To fix the pb I put the call to setMaxRetained() in the PushedNotifications constructor, but you can either put it just after the PushedNotifications object is created.
PushedNotifications all = new PushedNotifications(capacity); all.setMaxRetained(capacity);
From sype...@gmail.com on January 19, 2012 15:42:51 Fixed in r351 (in source code only, will be part of the next build).
Original author: ericpr...@gmail.com (January 19, 2012 08:28:59)
What steps will reproduce the problem?
What is the expected output? What do you see instead? I expect to have 1500 PushedNotifications in the returned PushedNotifications collection. I got instead the last 1000 Notifications.
What version of the product are you using? On what operating system?
Latest beta (2.2 beta3).
Please provide any additional information below.
To fix the problem simply add a call to setMaxRetain in the constructor of PushedNotifications(int capacity) like this:
/* * Construct an empty list of PushedNotification objects with a suggested * initial capacity. * * @param capacity / public PushedNotifications(int capacity) { super(capacity); setMaxRetained(capacity); }
Original issue: http://code.google.com/p/javapns/issues/detail?id=101