[
https://issues.apache.org/jira/browse/HBASE-22453?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
lixiaobao updated HBASE-22453:
------------------------------
Attachment: (was: HBASE-22453.patch)
> A "NullPointerException" could be thrown; "tableDescriptor" is nullable
> -----------------------------------------------------------------------
>
> Key: HBASE-22453
> URL: https://issues.apache.org/jira/browse/HBASE-22453
> Project: HBase
> Issue Type: Bug
> Components: backup&restore
> Affects Versions: 2.0.0, 2.1.2, 2.1.4
> Reporter: lixiaobao
> Assignee: lixiaobao
> Priority: Critical
> Fix For: 3.0.0
>
> Attachments: HBASE-22453.patch
>
>
> In hbase-backup model the class
> "org.apache.hadoop.hbase.backup.util.RestoreTool"'s method
> incrementalRestoreTable(),A "NullPointerException" could be thrown;
> "tableDescriptor" is nullable here.
> {code:java}
> // adjust table schema
> for (int i = 0; i < tableNames.length; i++) {
> TableName tableName = tableNames[i];
> TableDescriptor tableDescriptor = getTableDescriptor(fileSys, tableName,
> incrBackupId);
> LOG.debug("Found descriptor " + tableDescriptor + " through " +
> incrBackupId);
> TableName newTableName = newTableNames[i];
> TableDescriptor newTableDescriptor = admin.getDescriptor(newTableName);
> List<ColumnFamilyDescriptor> families =
> Arrays.asList(tableDescriptor.getColumnFamilies());
> List<ColumnFamilyDescriptor> existingFamilies =
> Arrays.asList(newTableDescriptor.getColumnFamilies());
> TableDescriptorBuilder builder =
> TableDescriptorBuilder.newBuilder(newTableDescriptor);
> boolean schemaChangeNeeded = false;
> for (ColumnFamilyDescriptor family : families) {
> if (!existingFamilies.contains(family)) {
> builder.setColumnFamily(family);
> schemaChangeNeeded = true;
> }
> }
> for (ColumnFamilyDescriptor family : existingFamilies) {
> if (!families.contains(family)) {
> builder.removeColumnFamily(family.getName());
> schemaChangeNeeded = true;
> }
> }
> if (schemaChangeNeeded) {
> modifyTableSync(conn, builder.build());
> LOG.info("Changed " + newTableDescriptor.getTableName() + " to: " +
> newTableDescriptor);
> }
> }
> RestoreJob restoreService = BackupRestoreFactory.getRestoreJob(conf);
> restoreService.run(logDirs, tableNames, newTableNames, false);
> }
> //代码占位符
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)