Skip to content

Commit

Permalink
Fix bug that arrises when logstreams are returned from the API with n…
Browse files Browse the repository at this point in the history
…o first and/or last event set
  • Loading branch information
cartwrightian committed Nov 14, 2018
1 parent 96c4d2b commit ddc8d4d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/tw/com/providers/LogClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,25 @@ private List<LogStream> getStreamsFor(String groupName, String token, long when)
logger.debug("Next token was: " + nextToken);
boolean tooOld = false;
for (LogStream stream : logStreams) {
long firstEvent = stream.getFirstEventTimestamp()==null ? Long.MAX_VALUE : stream.getFirstEventTimestamp();
long lastEvent = stream.getLastEventTimestamp()==null ? Long.MAX_VALUE : stream.getLastEventTimestamp();
DateTime firstDate = new DateTime(firstEvent);
DateTime lastDate = new DateTime(lastEvent);
String streamName = stream.getLogStreamName();
String logStreamName = stream.getLogStreamName();
logger.debug(format("Processing stream '%s' for group '%s", logStreamName, groupName));
Long firstEvent = stream.getFirstEventTimestamp();
Long lastEvent = stream.getLastEventTimestamp();

if (firstEvent==null) {
logger.warn(format("Group '%s' stream '%s' has null start event, assume in scope", groupName, logStreamName));
firstEvent = when + 1;
}
if (lastEvent==null) {
logger.warn(format("Group '%s' stream '%s' has null last event, assume in scope", groupName, logStreamName));
lastEvent = when + 1;
}

if (firstEvent>when || lastEvent>when) {
logger.info(format("Adding stream: %s first:%s last:%s", streamName, firstDate, lastDate));
logger.info(format("Adding stream: %s", logStreamName));
streamsForGroup.add(stream);
} else {
logger.info(format("Log stream '%s' is too old, spanned %s to %s", streamName, firstDate, lastDate));
logger.info(format("Log stream '%s' is too old", logStreamName));
tooOld = true;
break;
}
Expand Down

0 comments on commit ddc8d4d

Please sign in to comment.