Skip to content

Commit

Permalink
ISPN-11349 lock leak in SIFS FileProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
jhalliday authored and wburns committed Feb 18, 2020
1 parent 1f0b6b7 commit 029e169
Showing 1 changed file with 15 additions and 12 deletions.
Expand Up @@ -205,22 +205,25 @@ public CloseableIterator<Integer> getFileIterator() {

public void clear() throws IOException {
lock.writeLock().lock();
log.debug("Dropping all data");
while (currentOpenFiles.get() > 0) {
if (tryCloseFile()) {
if (currentOpenFiles.decrementAndGet() == 0) {
break;
try {
log.debug("Dropping all data");
while (currentOpenFiles.get() > 0) {
if (tryCloseFile()) {
if (currentOpenFiles.decrementAndGet() == 0) {
break;
}
}
}
}
if (!recordQueue.isEmpty()) throw new IllegalStateException();
if (!openFiles.isEmpty()) throw new IllegalStateException();
for (File file : dataDir.listFiles()) {
if (!file.delete()) {
throw new IOException("Cannot delete file " + file);
if (!recordQueue.isEmpty()) throw new IllegalStateException();
if (!openFiles.isEmpty()) throw new IllegalStateException();
for (File file : dataDir.listFiles()) {
if (!file.delete()) {
throw new IOException("Cannot delete file " + file);
}
}
} finally {
lock.writeLock().unlock();
}
lock.writeLock().unlock();
}

public void deleteFile(int fileId) {
Expand Down

0 comments on commit 029e169

Please sign in to comment.