asfgit closed pull request #23294: [SPARK-26265][Core][Followup] Put freePage
into a finally block
URL: https://github.com/apache/spark/pull/23294
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/core/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java
b/core/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java
index fbba002f1f80f..7df8aafb2b674 100644
--- a/core/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java
+++ b/core/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java
@@ -262,36 +262,39 @@ private void advanceToNextPage() {
// reference to the page to free and free it after releasing the lock of
`MapIterator`.
MemoryBlock pageToFree = null;
- synchronized (this) {
- int nextIdx = dataPages.indexOf(currentPage) + 1;
- if (destructive && currentPage != null) {
- dataPages.remove(currentPage);
- pageToFree = currentPage;
- nextIdx --;
- }
- if (dataPages.size() > nextIdx) {
- currentPage = dataPages.get(nextIdx);
- pageBaseObject = currentPage.getBaseObject();
- offsetInPage = currentPage.getBaseOffset();
- recordsInPage = UnsafeAlignedOffset.getSize(pageBaseObject,
offsetInPage);
- offsetInPage += UnsafeAlignedOffset.getUaoSize();
- } else {
- currentPage = null;
- if (reader != null) {
- handleFailedDelete();
+ try {
+ synchronized (this) {
+ int nextIdx = dataPages.indexOf(currentPage) + 1;
+ if (destructive && currentPage != null) {
+ dataPages.remove(currentPage);
+ pageToFree = currentPage;
+ nextIdx--;
}
- try {
- Closeables.close(reader, /* swallowIOException = */ false);
- reader = spillWriters.getFirst().getReader(serializerManager);
- recordsInPage = -1;
- } catch (IOException e) {
- // Scala iterator does not handle exception
- Platform.throwException(e);
+ if (dataPages.size() > nextIdx) {
+ currentPage = dataPages.get(nextIdx);
+ pageBaseObject = currentPage.getBaseObject();
+ offsetInPage = currentPage.getBaseOffset();
+ recordsInPage = UnsafeAlignedOffset.getSize(pageBaseObject,
offsetInPage);
+ offsetInPage += UnsafeAlignedOffset.getUaoSize();
+ } else {
+ currentPage = null;
+ if (reader != null) {
+ handleFailedDelete();
+ }
+ try {
+ Closeables.close(reader, /* swallowIOException = */ false);
+ reader = spillWriters.getFirst().getReader(serializerManager);
+ recordsInPage = -1;
+ } catch (IOException e) {
+ // Scala iterator does not handle exception
+ Platform.throwException(e);
+ }
}
}
- }
- if (pageToFree != null) {
- freePage(pageToFree);
+ } finally {
+ if (pageToFree != null) {
+ freePage(pageToFree);
+ }
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]