Skip to content

Commit

Permalink
Merge pull request #20 from castle/fix/invalid-queue-removal
Browse files Browse the repository at this point in the history
Do not remove item from queue when iterating
  • Loading branch information
aalekz committed Feb 27, 2019
2 parents 8a4dfe5 + eb1b683 commit 101e0c5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions castle/src/main/java/io/castle/android/queue/EventQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ public synchronized void flush() throws IOException {
Iterator<Event> iterator = eventObjectQueue.iterator();
for (int i = 0; i < end; i++) {
Event event = iterator.next();
if (event == null) {
iterator.remove();
} else {
if (event != null) {
subList.add(event);
}
}
Expand All @@ -103,9 +101,9 @@ public synchronized void flush() throws IOException {
Batch batch = new Batch();
batch.addEvents(events);

CastleLogger.d("Flushing EventQueue " + events.size());
CastleLogger.d("Flushing EventQueue " + end);

flushCount = events.size();
flushCount = end;
flushCall = CastleAPIService.getInstance().batch(batch);
flushCall.enqueue(this);
} else {
Expand Down

0 comments on commit 101e0c5

Please sign in to comment.