You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by rm...@apache.org on 2024/09/18 19:59:47 UTC
(hbase) branch 28842-branch-3 created (now 17c3df8f957)
This is an automated email from the ASF dual-hosted git repository.
rmattingly pushed a change to branch 28842-branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
at 17c3df8f957 HBASE-28842 TestRequestAttributes should fail when expected (#6255)
This branch includes the following new commits:
new 17c3df8f957 HBASE-28842 TestRequestAttributes should fail when expected (#6255)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(hbase) 01/01: HBASE-28842 TestRequestAttributes should fail when expected (#6255)
Posted by rm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rmattingly pushed a commit to branch 28842-branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 17c3df8f957d27a4b6e2b3179d1a9d732e83e8e8
Author: eab148 <54...@users.noreply.github.com>
AuthorDate: Wed Sep 18 15:43:43 2024 -0400
HBASE-28842 TestRequestAttributes should fail when expected (#6255)
Co-authored-by: Evie Boland <eb...@hubspot.com>
Signed-off-by: Ray Mattingly <rm...@apache.org>
Signed-off-by: Nick Dimiduk <nd...@apache.org>
---
.../hadoop/hbase/client/TestRequestAttributes.java | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRequestAttributes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRequestAttributes.java
index 66486ebcdd2..c9c19c36326 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRequestAttributes.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRequestAttributes.java
@@ -87,7 +87,7 @@ public class TestRequestAttributes {
ROW_KEY_TO_REQUEST_ATTRIBUTES.put(ROW_KEY5, addRandomRequestAttributes());
ROW_KEY_TO_REQUEST_ATTRIBUTES.put(ROW_KEY6, addRandomRequestAttributes());
ROW_KEY_TO_REQUEST_ATTRIBUTES.put(ROW_KEY7, addRandomRequestAttributes());
- ROW_KEY_TO_REQUEST_ATTRIBUTES.put(ROW_KEY8, new HashMap<>());
+ ROW_KEY_TO_REQUEST_ATTRIBUTES.put(ROW_KEY8, new HashMap<String, byte[]>());
}
private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(100);
private static final byte[] FAMILY = Bytes.toBytes("0");
@@ -316,20 +316,26 @@ public class TestRequestAttributes {
@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get,
List<Cell> result) throws IOException {
- validateRequestAttributes(getRequestAttributesForRowKey(get.getRow()));
+ if (!isValidRequestAttributes(getRequestAttributesForRowKey(get.getRow()))) {
+ throw new IOException("Incorrect request attributes");
+ }
}
@Override
public boolean preScannerNext(ObserverContext<RegionCoprocessorEnvironment> c,
InternalScanner s, List<Result> result, int limit, boolean hasNext) throws IOException {
- validateRequestAttributes(REQUEST_ATTRIBUTES_SCAN);
+ if (!isValidRequestAttributes(REQUEST_ATTRIBUTES_SCAN)) {
+ throw new IOException("Incorrect request attributes");
+ }
return hasNext;
}
@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit)
throws IOException {
- validateRequestAttributes(getRequestAttributesForRowKey(put.getRow()));
+ if (!isValidRequestAttributes(getRequestAttributesForRowKey(put.getRow()))) {
+ throw new IOException("Incorrect request attributes");
+ }
}
private Map<String, byte[]> getRequestAttributesForRowKey(byte[] rowKey) {
@@ -341,20 +347,21 @@ public class TestRequestAttributes {
return null;
}
- private void validateRequestAttributes(Map<String, byte[]> requestAttributes) {
+ private boolean isValidRequestAttributes(Map<String, byte[]> requestAttributes) {
RpcCall rpcCall = RpcServer.getCurrentCall().get();
Map<String, byte[]> attrs = rpcCall.getRequestAttributes();
if (attrs.size() != requestAttributes.size()) {
- return;
+ return false;
}
for (Map.Entry<String, byte[]> attr : attrs.entrySet()) {
if (!requestAttributes.containsKey(attr.getKey())) {
- return;
+ return false;
}
if (!Arrays.equals(requestAttributes.get(attr.getKey()), attr.getValue())) {
- return;
+ return false;
}
}
+ return true;
}
}
}