Skip to content

Commit 5a044b8

Browse files
committed
[#noissue] Backport: Add NPE Check in Hbase plugin
1 parent d483b23 commit 5a044b8

File tree

1 file changed

+8
-6
lines changed
  • plugins/hbase/src/main/java/com/navercorp/pinpoint/plugin/hbase/interceptor/data

1 file changed

+8
-6
lines changed

plugins/hbase/src/main/java/com/navercorp/pinpoint/plugin/hbase/interceptor/data/DataSizeUtils.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.navercorp.pinpoint.plugin.hbase.interceptor.data;
22

3+
import com.navercorp.pinpoint.common.util.ArrayUtils;
34
import org.apache.hadoop.hbase.Cell;
45
import org.apache.hadoop.hbase.client.Mutation;
56
import org.apache.hadoop.hbase.client.Result;
67

8+
import java.util.Collection;
79
import java.util.List;
810
import java.util.Map;
911
import java.util.NavigableMap;
@@ -24,11 +26,11 @@ private DataSizeUtils() {
2426
}
2527

2628
public static int sizeOfMutation(Mutation mutation) {
27-
return mutation.getRow().length + sumOfFamilyCellMap(mutation.getFamilyCellMap());
29+
return ArrayUtils.getLength(mutation.getRow()) + sumOfFamilyCellMap(mutation.getFamilyCellMap());
2830
}
2931

3032
public static int sizeOfResult(Result result) {
31-
return result.getRow().length + sumOfResultFamilyMap(result.getNoVersionMap());
33+
return ArrayUtils.getLength(result.getRow()) + sumOfResultFamilyMap(result.getNoVersionMap());
3234
}
3335

3436
public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
@@ -37,7 +39,7 @@ public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
3739
}
3840
int sizeInByte = 0;
3941
for (Map.Entry<byte[], List<Cell>> e : map.entrySet()) {
40-
sizeInByte += e.getKey().length;
42+
sizeInByte += ArrayUtils.getLength(e.getKey());
4143
for (Cell cell : e.getValue()) {
4244
sizeInByte += lengthOfCell(cell);
4345
}
@@ -48,10 +50,10 @@ public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
4850
public static int sumOfResultFamilyMap(NavigableMap<byte[], NavigableMap<byte[], byte[]>> map) {
4951
int sizeInByte = 0;
5052
for (Map.Entry<byte[], NavigableMap<byte[], byte[]>> familyToRest : map.entrySet()) {
51-
sizeInByte += familyToRest.getKey().length;
53+
sizeInByte += ArrayUtils.getLength(familyToRest.getKey());
5254
for (Map.Entry<byte[], byte[]> qualifierToValue : familyToRest.getValue().entrySet()) {
53-
sizeInByte += qualifierToValue.getKey().length;
54-
sizeInByte += qualifierToValue.getValue().length;
55+
sizeInByte += ArrayUtils.getLength(qualifierToValue.getKey());
56+
sizeInByte += ArrayUtils.getLength(qualifierToValue.getValue());
5557
}
5658
}
5759
return sizeInByte;

0 commit comments

Comments
 (0)