mirror of https://github.com/apache/druid.git
fix NPE when buffersList contains null in SmooshedFileMapper (#5689)
* fix NPE when buffersList contains null * address the comment
This commit is contained in:
parent
86746f82d8
commit
4db9e39a71
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package io.druid.java.util.common.io.smoosh;
|
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.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.io.Closeables;
|
import com.google.common.io.Closeables;
|
||||||
|
@ -143,6 +142,9 @@ public class SmooshedFileMapper implements Closeable
|
||||||
{
|
{
|
||||||
Throwable thrown = null;
|
Throwable thrown = null;
|
||||||
for (MappedByteBuffer mappedByteBuffer : buffersList) {
|
for (MappedByteBuffer mappedByteBuffer : buffersList) {
|
||||||
|
if (mappedByteBuffer == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ByteBufferUtils.unmap(mappedByteBuffer);
|
ByteBufferUtils.unmap(mappedByteBuffer);
|
||||||
}
|
}
|
||||||
|
@ -154,6 +156,9 @@ public class SmooshedFileMapper implements Closeable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Throwables.propagateIfPossible(thrown);
|
buffersList.clear();
|
||||||
|
if (thrown != null) {
|
||||||
|
throw new RuntimeException(thrown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue