diff --git a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java index c81208482..0ab2f44b4 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java @@ -731,14 +731,25 @@ else if(endDate == null) { // end date is null get all the inclusive the one record before the startdate Long startLong = new Long(startDate.getTime()); - files.add(startLong); - resultAsLong.addAll(files.subSet(startLong, files.last())); - resultAsLong.add(files.last()); + if(files.size() > 0 && + (startLong.longValue() < ((Long)files.first()).longValue())) + { + // if the start date is before any existing file date + // then return all the files + resultAsLong = files; + } + else + { + files.add(startLong); - // here we must get and the element before startLong - resultAsLong.add(files.subSet(files.first(), startLong).last()); - resultAsLong.remove(startLong); + resultAsLong.addAll(files.subSet(startLong, files.last())); + resultAsLong.add(files.last()); + + // here we must get and the element before startLong + resultAsLong.add(files.subSet(files.first(), startLong).last()); + resultAsLong.remove(startLong); + } } else {