void (Project project) { int historySize = getHistorySize(); final File[] files = TestStateStorage.getTestHistoryRoot(project).listFiles((dir, name) -> name.endsWith(".xml")); if (files != null && files.length >= historySize + 1) { Arrays.sort(files, (o1, o2) -> { final long l1 = o1.lastModified(); final long l2 = o2.lastModified(); if (l1 == l2) return FileUtil.compareFiles(o1, o2); return l1 < l2 ? -1 : 1; }); FileUtil.delete(files[0]); } }