fix NPE when buffersList contains null in SmooshedFileMapper (#5689)

* fix NPE when buffersList contains null

* address the comment
This commit is contained in:
kaijianding 2018-04-28 09:15:04 +08:00 committed by Gian Merlino
parent 86746f82d8
commit 4db9e39a71
1 changed files with 7 additions and 2 deletions

View File

@ -19,7 +19,6 @@
package io.druid.java.util.common.io.smoosh;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Closeables;
@ -143,6 +142,9 @@ public class SmooshedFileMapper implements Closeable
{
Throwable thrown = null;
for (MappedByteBuffer mappedByteBuffer : buffersList) {
if (mappedByteBuffer == null) {
continue;
}
try {
ByteBufferUtils.unmap(mappedByteBuffer);
}
@ -154,6 +156,9 @@ public class SmooshedFileMapper implements Closeable
}
}
}
Throwables.propagateIfPossible(thrown);
buffersList.clear();
if (thrown != null) {
throw new RuntimeException(thrown);
}
}
}