Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[#10310] Backport: Add NPE Check in Hbase plugin #10307

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.navercorp.pinpoint.plugin.hbase.interceptor.data;

import com.navercorp.pinpoint.common.util.ArrayUtils;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Result;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
Expand All @@ -24,11 +26,11 @@ private DataSizeUtils() {
}

public static int sizeOfMutation(Mutation mutation) {
return mutation.getRow().length + sumOfFamilyCellMap(mutation.getFamilyCellMap());
return ArrayUtils.getLength(mutation.getRow()) + sumOfFamilyCellMap(mutation.getFamilyCellMap());
}

public static int sizeOfResult(Result result) {
return result.getRow().length + sumOfResultFamilyMap(result.getNoVersionMap());
return ArrayUtils.getLength(result.getRow()) + sumOfResultFamilyMap(result.getNoVersionMap());
}

public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
Expand All @@ -37,7 +39,7 @@ public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
}
int sizeInByte = 0;
for (Map.Entry<byte[], List<Cell>> e : map.entrySet()) {
sizeInByte += e.getKey().length;
sizeInByte += ArrayUtils.getLength(e.getKey());
for (Cell cell : e.getValue()) {
sizeInByte += lengthOfCell(cell);
}
Expand All @@ -48,10 +50,10 @@ public static int sumOfFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
public static int sumOfResultFamilyMap(NavigableMap<byte[], NavigableMap<byte[], byte[]>> map) {
int sizeInByte = 0;
for (Map.Entry<byte[], NavigableMap<byte[], byte[]>> familyToRest : map.entrySet()) {
sizeInByte += familyToRest.getKey().length;
sizeInByte += ArrayUtils.getLength(familyToRest.getKey());
for (Map.Entry<byte[], byte[]> qualifierToValue : familyToRest.getValue().entrySet()) {
sizeInByte += qualifierToValue.getKey().length;
sizeInByte += qualifierToValue.getValue().length;
sizeInByte += ArrayUtils.getLength(qualifierToValue.getKey());
sizeInByte += ArrayUtils.getLength(qualifierToValue.getValue());
}
}
return sizeInByte;
Expand Down