[HUDI-3263] Do not nullify members in HoodieTableFileSystemView#resetViewState to avoid NPE (#4625)
This commit is contained in:
@@ -114,11 +114,22 @@ public class HoodieTableFileSystemView extends IncrementalTimelineSyncFileSystem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void resetViewState() {
|
protected void resetViewState() {
|
||||||
this.fgIdToPendingCompaction = null;
|
// do not nullify the members to avoid NPE.
|
||||||
this.partitionToFileGroupsMap = null;
|
|
||||||
this.fgIdToBootstrapBaseFile = null;
|
// there are two cases that #resetViewState is called:
|
||||||
this.fgIdToReplaceInstants = null;
|
// 1. when #sync is invoked, the view clear the state through calling #resetViewState,
|
||||||
this.fgIdToPendingClustering = null;
|
// then re-initialize the view;
|
||||||
|
// 2. when #close is invoked.
|
||||||
|
// (see AbstractTableFileSystemView for details.)
|
||||||
|
|
||||||
|
// for the 1st case, we better do not nullify the members when #resetViewState
|
||||||
|
// because there is possibility that this in-memory view is a backend view under TimelineServer,
|
||||||
|
// and many methods in the RequestHandler is not thread safe, when performRefreshCheck flag in ViewHandler
|
||||||
|
// is set as false, the view does not perform refresh check, if #sync is called just before and the members
|
||||||
|
// are nullified, the methods that use these members would throw NPE.
|
||||||
|
|
||||||
|
// actually there is no need to nullify the members here for 1st case, the members are assigned with new values
|
||||||
|
// when calling #init, for 2nd case, the #close method already nullify the members.
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, List<HoodieFileGroup>> createPartitionToFileGroups() {
|
protected Map<String, List<HoodieFileGroup>> createPartitionToFileGroups() {
|
||||||
@@ -350,10 +361,11 @@ public class HoodieTableFileSystemView extends IncrementalTimelineSyncFileSystem
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
super.close();
|
super.close();
|
||||||
partitionToFileGroupsMap = null;
|
this.fgIdToPendingCompaction = null;
|
||||||
fgIdToPendingCompaction = null;
|
this.partitionToFileGroupsMap = null;
|
||||||
fgIdToBootstrapBaseFile = null;
|
this.fgIdToBootstrapBaseFile = null;
|
||||||
fgIdToReplaceInstants = null;
|
this.fgIdToReplaceInstants = null;
|
||||||
|
this.fgIdToPendingClustering = null;
|
||||||
closed = true;
|
closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user