From 0d5a678ac9d60c6c93c3378bbdf712ed76c73c32 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 29 May 2013 16:21:33 +0000 Subject: [PATCH] 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 --- .../hadoop/hbase/regionserver/HRegionServer.java | 12 ++++++------ .../hadoop/hbase/util/hbck/TableLockChecker.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 3dc91d0628c..2ac2d491051 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -2829,7 +2829,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa PayloadCarryingRpcController controller = (PayloadCarryingRpcController)rpcc; CellScanner cellScanner = controller != null? controller.cellScanner(): null; // Clear scanner so we are not holding on to reference across call. - controller.setCellScanner(null); + if (controller != null) controller.setCellScanner(null); try { requestCount.increment(); HRegion region = getRegion(request.getRegion()); @@ -2915,7 +2915,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa builder.setResult(ProtobufUtil.toResultNoData(r)); cellsToReturn = r; } - if (cellsToReturn != null) { + if (controller != null && cellsToReturn != null) { controller.setCellScanner(cellsToReturn.cellScanner()); } 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. // It is also the conduit via which we pass back data. 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. - controller.setCellScanner(null); + if (controller != null) controller.setCellScanner(null); List cellsToReturn = null; try { HRegion region = getRegion(request.getRegion()); @@ -3265,7 +3265,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa } } // 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)); } return builder.build(); @@ -3739,7 +3739,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa PayloadCarryingRpcController controller = (PayloadCarryingRpcController) rpcc; CellScanner cellScanner = controller != null ? controller.cellScanner() : null; // Clear scanner so we are not holding on to reference across call. - controller.setCellScanner(null); + if (controller != null) controller.setCellScanner(null); try { checkOpen(); HRegion region = getRegion(request.getRegion()); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/TableLockChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/TableLockChecker.java index 287675390ad..a7afc108b52 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/TableLockChecker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/TableLockChecker.java @@ -65,7 +65,7 @@ public class TableLockChecker { 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); } else { errorReporter.print(msg);