Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -43,7 +43,7 @@

import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;

public class KeymetaTestUtils {
public final class KeymetaTestUtils {

/**
* A ByteArrayInputStream that implements Seekable and PositionedReadable to work with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,9 @@ public void testGetKeyMetadataHashEncoded() {
@Test
public void testGetKeyMetadataHashEncodedWithNullHash() {
// Create ManagedKeyData with FAILED state and null metadata
// Passing null for metadata should result in null hash.
ManagedKeyData keyData =
new ManagedKeyData("custodian".getBytes(), "namespace", null, ManagedKeyState.FAILED, null // null
// metadata
// should
// result
// in
// null
// hash
);
new ManagedKeyData("custodian".getBytes(), "namespace", null, ManagedKeyState.FAILED, null);

String encoded = keyData.getKeyMetadataHashEncoded();
assertNull(encoded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void testNamespaceMismatchReturnsFailedKey() throws Exception {
assertEquals(ManagedKeyState.FAILED, keyData.getKeyState());
assertNull(keyData.getTheKey());
assertEquals(requestedNamespace, keyData.getKeyNamespace());
assertEquals(firstCust, keyData.getKeyCustodian());
assertTrue(Bytes.equals(firstCust.get(), keyData.getKeyCustodian()));
}

@Test
Expand Down Expand Up @@ -475,14 +475,14 @@ private void assertKeyDataWithNamespace(ManagedKeyData keyData, ManagedKeyState
} else {
byte[] keyBytes = keyData.getTheKey().getEncoded();
assertEquals(key.length, keyBytes.length);
assertEquals(new Bytes(key), keyBytes);
assertTrue(Bytes.equals(key, keyBytes));
}

// Use helper method instead of duplicated parsing logic
String encodedCust = Base64.getEncoder().encodeToString(custBytes);
assertMetadataMatches(keyData.getKeyMetadata(), alias, encodedCust, expectedNamespace);

assertEquals(new Bytes(custBytes), keyData.getKeyCustodian());
assertTrue(Bytes.equals(custBytes, keyData.getKeyCustodian()));
assertEquals(keyData, managedKeyProvider.unwrapKey(keyData.getKeyMetadata(), null));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
*/
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class KeyNamespaceUtil {
public final class KeyNamespaceUtil {
private KeyNamespaceUtil() {
throw new UnsupportedOperationException("Cannot instantiate utility class");
}

/**
* Construct a key namespace from a table descriptor and column family descriptor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ public ActiveKeysCacheKey(byte[] custodian, String namespace) {

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
ActiveKeysCacheKey cacheKey = (ActiveKeysCacheKey) obj;
return Bytes.equals(custodian, cacheKey.custodian)
&& Objects.equals(namespace, cacheKey.namespace);
Expand Down Expand Up @@ -161,7 +165,8 @@ public ManagedKeyData getEntry(byte[] key_cust, String keyNamespace, String keyM
}
return keyData;
});
if (ManagedKeyState.isUsable(entry.getKeyState())) {
// This should never be null, but adding a check just to satisfy spotbugs.
if (entry != null && ManagedKeyState.isUsable(entry.getKeyState())) {
return entry;
}
return null;
Expand Down Expand Up @@ -241,7 +246,8 @@ public ManagedKeyData getActiveEntry(byte[] key_cust, String keyNamespace) {
return retrievedKey;
});

if (keyData.getKeyState() == ManagedKeyState.ACTIVE) {
// This should never be null, but adding a check just to satisfy spotbugs.
if (keyData!= null && keyData.getKeyState() == ManagedKeyState.ACTIVE) {
return keyData;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ public void testWithKeyManagement_LocalKeyGen_WithKeyAlgorithmMismatch() throws
configBuilder().withKeyManagement(true).apply(conf);
setupManagedKeyDataCache(testTableNamespace, mockManagedKeyData);
assertEncryptionContextThrowsForWrites(IllegalStateException.class,
"Encryption for family 'test-family' configured with type 'AES' but key specifies algorithm 'DES'");
"Encryption for family 'test-family' configured with type 'AES' but key specifies "
+ "algorithm 'DES'");
}

@Test
Expand Down Expand Up @@ -472,7 +473,8 @@ public void testWithoutKeyManagement_KeyAlgorithmMismatch() throws Exception {
when(mockFamily.getEncryptionKey()).thenReturn(wrappedDESKey);

assertEncryptionContextThrowsForWrites(IllegalStateException.class,
"Encryption for family 'test-family' configured with type 'AES' but key specifies algorithm 'DES'");
"Encryption for family 'test-family' configured with type 'AES' but key specifies "
+ "algorithm 'DES'");
}

@Test
Expand Down
1 change: 0 additions & 1 deletion hbase-shell/src/main/ruby/shell/commands/rotate_stk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ def command
end
end
end

5 changes: 2 additions & 3 deletions hbase-shell/src/test/ruby/tests_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
end

files = Dir[ File.dirname(__FILE__) + "/" + test_suite_pattern ]
if files.empty?
raise "No tests found for #{test_suite_pattern}"
end
raise "No tests found for #{test_suite_pattern}" if files.empty?

files.each do |file|
filename = File.basename(file)
if includes != nil && !includes.include?(filename)
Expand Down