Skip to content

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

api/iceberg-service/src/main/java/org/apache/polaris/service/types/NotificationType.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.polaris.service.types;
2020

2121
import java.util.Arrays;
22-
import java.util.Locale;
2322
import java.util.Map;
2423
import java.util.Optional;
2524
import java.util.stream.Collectors;
@@ -84,9 +83,9 @@ public static Optional<NotificationType> lookupByName(String name) {
8483
return Optional.empty();
8584
}
8685

87-
for (NotificationType NotificationType : NotificationType.values()) {
88-
if (name.toUpperCase(Locale.ROOT).equals(NotificationType.name())) {
89-
return Optional.of(NotificationType);
86+
for (NotificationType notificationType : NotificationType.values()) {
87+
if (name.equalsIgnoreCase(notificationType.name())) {
88+
return Optional.of(notificationType);
9089
}
9190
}
9291
return Optional.empty();

codestyle/errorprone-rules.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ UseCorrectAssertInTests=ERROR
227227
ConstantPatternCompile=ERROR
228228
# Variables initialized with Pattern#compile calls on constants can be constants
229229

230+
ObjectsHashCodePrimitive=ERROR
231+
# Objects.hashCode(Object o) should not be passed a primitive value
232+
233+
OptionalMapToOptional=ERROR
234+
# Mapping to another Optional will yield a nested Optional. Did you mean flatMap?
235+
230236
PrimitiveArrayPassedToVarargsMethod=ERROR
231237
# Passing a primitive array to a varargs method is usually wrong
232238

@@ -239,6 +245,9 @@ RedundantThrows=ERROR
239245
StringCaseLocaleUsage=ERROR
240246
# Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.)
241247

248+
StringCharset=ERROR
249+
# Prefer StandardCharsets over using string names for charsets
250+
242251
StronglyTypeByteString=WARN
243252
# This primitive byte array is only used to construct ByteStrings. It would be clearer to strongly type the field instead.
244253

@@ -254,6 +263,9 @@ TransientMisuse=ERROR
254263
UrlInSee=ERROR
255264
# URLs should not be used in @see tags; they are designed for Java elements which could be used with @link.
256265

266+
VariableNameSameAsType=ERROR
267+
# variableName and type with the same name would refer to the static field instead of the class
268+
257269
####################################################################################################
258270
# Experimental : SUGGESTION
259271
# See https://errorprone.info/bugpatterns

polaris-core/src/main/java/org/apache/polaris/core/secrets/UnsafeInMemorySecretsManager.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.apache.polaris.core.secrets;
2020

2121
import jakarta.annotation.Nonnull;
22-
import java.io.UnsupportedEncodingException;
22+
import java.nio.charset.StandardCharsets;
2323
import java.security.SecureRandom;
2424
import java.util.Base64;
2525
import java.util.HashMap;
@@ -54,12 +54,7 @@ public UserSecretReference writeSecret(
5454
// secret as well as the secretReferencePayload to recover the original secret, we'll use
5555
// basic XOR encryption and store the randomly generated key in the reference payload.
5656
// A production implementation will typically use a standard crypto library if applicable.
57-
byte[] secretBytes;
58-
try {
59-
secretBytes = secret.getBytes("UTF-8");
60-
} catch (UnsupportedEncodingException e) {
61-
throw new RuntimeException(e);
62-
}
57+
byte[] secretBytes = secret.getBytes(StandardCharsets.UTF_8);
6358
byte[] oneTimeKey = new byte[secretBytes.length];
6459
byte[] cipherTextBytes = new byte[secretBytes.length];
6560

@@ -143,11 +138,7 @@ public String readSecret(@Nonnull UserSecretReference secretReference) {
143138
secretBytes[i] = (byte) (cipherTextBytes[i] ^ oneTimeKey[i]);
144139
}
145140

146-
try {
147-
return new String(secretBytes, "UTF-8");
148-
} catch (UnsupportedEncodingException e) {
149-
throw new RuntimeException(e);
150-
}
141+
return new String(secretBytes, StandardCharsets.UTF_8);
151142
}
152143

153144
/** {@inheritDoc} */

polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageIntegration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import jakarta.annotation.Nonnull;
2222
import java.util.EnumMap;
2323
import java.util.Map;
24-
import java.util.Objects;
2524
import java.util.Set;
2625
import org.apache.polaris.core.PolarisDiagnostics;
2726

@@ -129,7 +128,7 @@ public boolean equals(Object o) {
129128

130129
@Override
131130
public int hashCode() {
132-
return Objects.hashCode(success);
131+
return Boolean.hashCode(success);
133132
}
134133

135134
@Override

quarkus/service/src/main/java/org/apache/polaris/service/quarkus/config/ProductionReadinessChecks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public ProductionReadinessCheck checkTokenBrokers(
151151
if (config
152152
.tokenBroker()
153153
.symmetricKey()
154-
.map(SymmetricKeyConfiguration::secret)
154+
.flatMap(SymmetricKeyConfiguration::secret)
155155
.isPresent()) {
156156
errors.add(
157157
Error.of(

0 commit comments

Comments
 (0)