Skip to content

Commit

Permalink
fix NPE when buffersList contains null in SmooshedFileMapper (apache#…
Browse files Browse the repository at this point in the history
…5689)

* fix NPE when buffersList contains null

* address the comment
  • Loading branch information
kaijianding authored and gianm committed Apr 28, 2018
1 parent 86746f8 commit 4db9e39
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,6 +142,9 @@ public void close()
{
Throwable thrown = null;
for (MappedByteBuffer mappedByteBuffer : buffersList) {
if (mappedByteBuffer == null) {
continue;
}
try {
ByteBufferUtils.unmap(mappedByteBuffer);
}
Expand All @@ -154,6 +156,9 @@ public void close()
}
}
}
Throwables.propagateIfPossible(thrown);
buffersList.clear();
if (thrown != null) {
throw new RuntimeException(thrown);
}
}
}

0 comments on commit 4db9e39

Please sign in to comment.