HBASE-19939 Fixed NPE in tests TestSplitTableRegionProcedure#testSplitWithoutPONR() and testRecoveryAndDoubleExecution()

Value of 'htd' is null as it is initialized in the constructor but when the object is deserialized its null. Got rid of member variable htd and made it local to method.
This commit is contained in:
Umesh Agashe 2018-02-05 12:08:49 -08:00 committed by Michael Stack
parent 8b6b3326a6
commit 53e5707224
No known key found for this signature in database
GPG Key ID: 9816C7FC8ACC93D2
1 changed files with 4 additions and 4 deletions

View File

@ -94,7 +94,6 @@ public class SplitTableRegionProcedure
private RegionInfo daughter_1_RI; private RegionInfo daughter_1_RI;
private RegionInfo daughter_2_RI; private RegionInfo daughter_2_RI;
private byte[] bestSplitRow; private byte[] bestSplitRow;
private TableDescriptor htd;
private RegionSplitPolicy splitPolicy; private RegionSplitPolicy splitPolicy;
public SplitTableRegionProcedure() { public SplitTableRegionProcedure() {
@ -120,14 +119,14 @@ public class SplitTableRegionProcedure
.setSplit(false) .setSplit(false)
.setRegionId(rid) .setRegionId(rid)
.build(); .build();
this.htd = env.getMasterServices().getTableDescriptors().get(getTableName()); TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(getTableName());
if(this.htd.getRegionSplitPolicyClassName() != null) { if(htd.getRegionSplitPolicyClassName() != null) {
// Since we don't have region reference here, creating the split policy instance without it. // Since we don't have region reference here, creating the split policy instance without it.
// This can be used to invoke methods which don't require Region reference. This instantiation // This can be used to invoke methods which don't require Region reference. This instantiation
// of a class on Master-side though it only makes sense on the RegionServer-side is // of a class on Master-side though it only makes sense on the RegionServer-side is
// for Phoenix Local Indexing. Refer HBASE-12583 for more information. // for Phoenix Local Indexing. Refer HBASE-12583 for more information.
Class<? extends RegionSplitPolicy> clazz = Class<? extends RegionSplitPolicy> clazz =
RegionSplitPolicy.getSplitPolicyClass(this.htd, env.getMasterConfiguration()); RegionSplitPolicy.getSplitPolicyClass(htd, env.getMasterConfiguration());
this.splitPolicy = ReflectionUtils.newInstance(clazz, env.getMasterConfiguration()); this.splitPolicy = ReflectionUtils.newInstance(clazz, env.getMasterConfiguration());
} }
} }
@ -611,6 +610,7 @@ public class SplitTableRegionProcedure
maxThreads, Threads.getNamedThreadFactory("StoreFileSplitter-%1$d")); maxThreads, Threads.getNamedThreadFactory("StoreFileSplitter-%1$d"));
final List<Future<Pair<Path,Path>>> futures = new ArrayList<Future<Pair<Path,Path>>>(nbFiles); final List<Future<Pair<Path,Path>>> futures = new ArrayList<Future<Pair<Path,Path>>>(nbFiles);
TableDescriptor htd = env.getMasterServices().getTableDescriptors().get(getTableName());
// Split each store file. // Split each store file.
for (Map.Entry<String, Collection<StoreFileInfo>>e: files.entrySet()) { for (Map.Entry<String, Collection<StoreFileInfo>>e: files.entrySet()) {
byte [] familyName = Bytes.toBytes(e.getKey()); byte [] familyName = Bytes.toBytes(e.getKey());