HBASE-8634 Fix potential null pointer dereference in HRegionServer and TableLockChecker (Ted Yu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1487533 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-05-29 16:21:33 +00:00
parent 3105761d0a
commit 0d5a678ac9
2 changed files with 7 additions and 7 deletions

View File

@ -2829,7 +2829,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
PayloadCarryingRpcController controller = (PayloadCarryingRpcController)rpcc; PayloadCarryingRpcController controller = (PayloadCarryingRpcController)rpcc;
CellScanner cellScanner = controller != null? controller.cellScanner(): null; CellScanner cellScanner = controller != null? controller.cellScanner(): null;
// Clear scanner so we are not holding on to reference across call. // Clear scanner so we are not holding on to reference across call.
controller.setCellScanner(null); if (controller != null) controller.setCellScanner(null);
try { try {
requestCount.increment(); requestCount.increment();
HRegion region = getRegion(request.getRegion()); HRegion region = getRegion(request.getRegion());
@ -2915,7 +2915,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
builder.setResult(ProtobufUtil.toResultNoData(r)); builder.setResult(ProtobufUtil.toResultNoData(r));
cellsToReturn = r; cellsToReturn = r;
} }
if (cellsToReturn != null) { if (controller != null && cellsToReturn != null) {
controller.setCellScanner(cellsToReturn.cellScanner()); controller.setCellScanner(cellsToReturn.cellScanner());
} }
return builder.build(); return builder.build();
@ -3171,9 +3171,9 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
// rpc controller is how we bring in data via the back door; it is unprotobuf'ed data. // rpc controller is how we bring in data via the back door; it is unprotobuf'ed data.
// It is also the conduit via which we pass back data. // It is also the conduit via which we pass back data.
PayloadCarryingRpcController controller = (PayloadCarryingRpcController)rpcc; PayloadCarryingRpcController controller = (PayloadCarryingRpcController)rpcc;
CellScanner cellScanner = controller != null? controller.cellScanner(): null; CellScanner cellScanner = controller != null ? controller.cellScanner(): null;
// Clear scanner so we are not holding on to reference across call. // Clear scanner so we are not holding on to reference across call.
controller.setCellScanner(null); if (controller != null) controller.setCellScanner(null);
List<CellScannable> cellsToReturn = null; List<CellScannable> cellsToReturn = null;
try { try {
HRegion region = getRegion(request.getRegion()); HRegion region = getRegion(request.getRegion());
@ -3265,7 +3265,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
} }
} }
// Load the controller with the Cells to return. // Load the controller with the Cells to return.
if (cellsToReturn != null && !cellsToReturn.isEmpty()) { if (cellsToReturn != null && !cellsToReturn.isEmpty() && controller != null) {
controller.setCellScanner(CellUtil.createCellScanner(cellsToReturn)); controller.setCellScanner(CellUtil.createCellScanner(cellsToReturn));
} }
return builder.build(); return builder.build();
@ -3739,7 +3739,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
PayloadCarryingRpcController controller = (PayloadCarryingRpcController) rpcc; PayloadCarryingRpcController controller = (PayloadCarryingRpcController) rpcc;
CellScanner cellScanner = controller != null ? controller.cellScanner() : null; CellScanner cellScanner = controller != null ? controller.cellScanner() : null;
// Clear scanner so we are not holding on to reference across call. // Clear scanner so we are not holding on to reference across call.
controller.setCellScanner(null); if (controller != null) controller.setCellScanner(null);
try { try {
checkOpen(); checkOpen();
HRegion region = getRegion(request.getRegion()); HRegion region = getRegion(request.getRegion());

View File

@ -65,7 +65,7 @@ public class TableLockChecker {
data.getPurpose(), data.getIsShared(), data.getCreateTime()); data.getPurpose(), data.getIsShared(), data.getCreateTime());
} }
if (data.hasCreateTime() && data.getCreateTime() < expireDate) { if (data != null && data.hasCreateTime() && data.getCreateTime() < expireDate) {
errorReporter.reportError(HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK, msg); errorReporter.reportError(HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK, msg);
} else { } else {
errorReporter.print(msg); errorReporter.print(msg);