mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-38496 - IAE: WorkingContextManager.pack
This commit is contained in:
@@ -58,10 +58,9 @@ public class WorkingContextManager {
|
||||
private static final String CONTEXT_ZIP_POSTFIX = ".contexts.zip";
|
||||
private static final Comparator<JBZipEntry> ENTRY_COMPARATOR = new Comparator<JBZipEntry>() {
|
||||
public int compare(JBZipEntry o1, JBZipEntry o2) {
|
||||
return (int)(o2.getTime() - o1.getTime());
|
||||
return Long.signum(o2.getTime() - o1.getTime());
|
||||
}
|
||||
};
|
||||
private final Object myLock = new Object();
|
||||
|
||||
public static WorkingContextManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, WorkingContextManager.class);
|
||||
@@ -225,17 +224,15 @@ public class WorkingContextManager {
|
||||
private void pack(int max, int delta, String zipPostfix) {
|
||||
try {
|
||||
JBZipFile archive = getTasksArchive(zipPostfix);
|
||||
synchronized (myLock) {
|
||||
List<JBZipEntry> entries = archive.getEntries();
|
||||
if (entries.size() > max + delta) {
|
||||
JBZipEntry[] array = entries.toArray(new JBZipEntry[entries.size()]);
|
||||
Arrays.sort(array, ENTRY_COMPARATOR);
|
||||
for (int i = array.length - 1; i >= max; i--) {
|
||||
archive.eraseEntry(array[i]);
|
||||
}
|
||||
List<JBZipEntry> entries = archive.getEntries();
|
||||
if (entries.size() > max + delta) {
|
||||
JBZipEntry[] array = entries.toArray(new JBZipEntry[entries.size()]);
|
||||
Arrays.sort(array, ENTRY_COMPARATOR);
|
||||
for (int i = array.length - 1; i >= max; i--) {
|
||||
archive.eraseEntry(array[i]);
|
||||
}
|
||||
archive.close();
|
||||
}
|
||||
archive.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
|
||||
Reference in New Issue
Block a user