Skip to content

Commit

Permalink
Fix a bunch of IntelliJ inspections, rather nits + cosmetic (#8955)
Browse files Browse the repository at this point in the history
* Fix a bunch of IntelliJ inspections, rather nits + cosmetic

* fixup
  • Loading branch information
snazy authored Jun 28, 2024
1 parent 9cf5dc4 commit af04cbc
Show file tree
Hide file tree
Showing 89 changed files with 186 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public interface NessieApiV1 extends NessieApi {
* RefLogResponse.getToken()} in the next invocation of {@code getRefLog()} as the {@code
* pageToken} parameter.
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
GetRefLogBuilder getRefLog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class AuthorizationCodeFlow extends AbstractFlow {
redirectUriFuture
.thenApply(this::extractAuthorizationCode)
.thenApply(this::fetchNewTokens)
.whenComplete(this::log);
.whenComplete((tokens, error) -> log(error));
closeFuture.thenRun(this::doClose);
server =
createServer(config.getAuthorizationCodeFlowWebServerPort().orElse(0), this::doRequest);
Expand Down Expand Up @@ -228,7 +228,7 @@ private Tokens fetchNewTokens(String code) {
return tokens;
}

private void log(Tokens tokens, Throwable error) {
private void log(Throwable error) {
if (LOGGER.isDebugEnabled()) {
if (error == null) {
LOGGER.debug("Authorization Code Flow: tokens received");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Tokens fetchNewTokens(@Nullable Tokens currentTokens) {
} catch (ExecutionException e) {
abort();
Throwable cause = e.getCause();
LOGGER.error("Authentication failed: " + cause.getMessage());
LOGGER.error("Authentication failed: {}", cause.getMessage());
if (cause instanceof HttpClientException) {
throw (HttpClientException) cause;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static JwtToken parse(String token) {
if (token != null) {
@SuppressWarnings("StringSplitter")
String[] parts = token.split("\\.");
if (parts.length == 3 && parts[1].length() > 0) {
if (parts.length == 3 && !parts[1].isEmpty()) {
try {
JsonNode payload = OBJECT_MAPPER.readTree(Base64.getUrlDecoder().decode(parts[1]));
return new JwtToken(payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum Method {
GET,
POST,
PUT,
DELETE;
DELETE,
}

default HttpRequest newRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public interface BaseMergeTransplant {
message = Validation.REF_NAME_MESSAGE)
String getFromRefName();

@SuppressWarnings("DeprecatedIsStillUsed")
@Nullable
@jakarta.annotation.Nullable
@JsonInclude(Include.NON_NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ default boolean wasSuccessful() {
@jakarta.annotation.Nullable
String getExpectedHash();

@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated // for removal and replaced with something else
@Schema(deprecated = true, hidden = true)
@JsonView(Views.V1.class)
List<LogEntry> getSourceCommits();

@SuppressWarnings("DeprecatedIsStillUsed")
@Nullable
@jakarta.annotation.Nullable
@Deprecated // for removal and replaced with something else
Expand All @@ -102,6 +104,7 @@ interface ContentKeyDetails {

MergeBehavior getMergeBehavior();

@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated // for removal, #getConflict() is a proper replacement
@Value.Default
@JsonDeserialize(using = ContentKeyConflict.Deserializer.class)
Expand All @@ -111,11 +114,13 @@ default ContentKeyConflict getConflictType() {
return ContentKeyConflict.NONE;
}

@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated // for removal and replaced with something else
@Schema(deprecated = true, hidden = true)
@JsonView(Views.V1.class)
List<String> getSourceCommits();

@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated // for removal and replaced with something else
@Schema(deprecated = true, hidden = true)
@JsonView(Views.V1.class)
Expand All @@ -129,6 +134,7 @@ default ContentKeyConflict getConflictType() {
Conflict getConflict();
}

@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated // for removal
enum ContentKeyConflict {
NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static Builder builder() {
return ImmutableAdlsConfig.builder();
}

@SuppressWarnings("unused")
interface Builder {
@CanIgnoreReturnValue
Builder maxHttpConnections(int maxHttpConnections);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static Builder builder() {
return ImmutableAdlsProgrammaticOptions.builder();
}

@SuppressWarnings("unused")
interface Builder {
@CanIgnoreReturnValue
Builder readBlockSize(int readBlockSize);
Expand Down Expand Up @@ -92,6 +93,7 @@ static Builder builder() {

AdlsFileSystemOptions FALLBACK = AdlsPerFileSystemOptions.builder().build();

@SuppressWarnings("unused")
interface Builder {
@CanIgnoreReturnValue
Builder from(AdlsFileSystemOptions instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static Builder builder() {
return ImmutableGcsProgrammaticOptions.builder();
}

@SuppressWarnings("unused")
interface Builder {
@CanIgnoreReturnValue
Builder putBuckets(String bucket, GcsBucketOptions bucketOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ public enum IcebergDataContent {
DATA,
POSITION_DELETES,
EQUALITY_DELETES,
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
public enum IcebergManifestEntryStatus {
EXISTING,
ADDED,
DELETED;
DELETED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ default boolean compatibleWith(IcebergPartitionSpec other) {
IcebergPartitionField thisField = fields().get(i);
IcebergPartitionField thatField = other.fields().get(i);
if (thisField.sourceId() != thatField.sourceId()
|| !thisField.transform().toString().equals(thatField.transform().toString())
|| !thisField.transform().equals(thatField.transform())
|| !thisField.name().equals(thatField.name())) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.projectnessie.catalog.formats.iceberg.metrics;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
Expand Down Expand Up @@ -64,8 +63,7 @@ public void serialize(TimeUnit value, JsonGenerator gen, SerializerProvider seri

final class TimeUnitDeserializer extends JsonDeserializer<TimeUnit> {
@Override
public TimeUnit deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JacksonException {
public TimeUnit deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return TimeUnit.valueOf(p.getText().toUpperCase());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public static IcebergUnit fromString(String key) {

try {
return valueOf(key.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException var2) {
IllegalArgumentException e = var2;
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(String.format("Invalid unit: %s", key), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ public static void assignUUID(AssignUUID u, NessieEntitySnapshot<?> snapshot) {
String uuid = u.uuid();
Preconditions.checkArgument(uuid != null, "Null entity UUID is not permitted.");
Preconditions.checkArgument(
uuid.equals(Objects.requireNonNull(snapshot.entity().icebergUuid()).toString()),
uuid.equals(Objects.requireNonNull(snapshot.entity().icebergUuid())),
"UUID mismatch: assigned: %s, new: %s",
snapshot.entity().icebergUuid(),
uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import static java.lang.Integer.parseInt;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
Expand Down Expand Up @@ -108,8 +107,7 @@ public IcebergPrimitiveType deserialize(JsonParser p, DeserializationContext ctx

static final class IcebergTypeDeserializer extends JsonDeserializer<IcebergType> {
@Override
public IcebergType deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JacksonException {
public IcebergType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
switch (p.currentToken()) {
case VALUE_STRING:
return primitiveFromString(p.getValueAsString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.projectnessie.catalog.model.schema.types;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
Expand Down Expand Up @@ -81,7 +80,7 @@ public void serialize(NessieTypeSpec value, JsonGenerator gen, SerializerProvide
class NessieTypeSpecDeserializer extends JsonDeserializer<NessieTypeSpec> {
@Override
public NessieTypeSpec deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JacksonException {
throws IOException {
return p.readValueAs(NessieTypeSpecSerialized.class).unwrap();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@

public enum TableFormat {
ICEBERG,
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static Builder builder() {
return ImmutableCatalogCommit.builder();
}

@SuppressWarnings("unused")
interface Builder {
@CanIgnoreReturnValue
Builder from(CatalogCommit instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ public enum SnapshotFormat {
NESSIE_SNAPSHOT,
/** Iceberg table metadata. */
ICEBERG_TABLE_METADATA,
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ public enum SnapshotResultFormat {
ICEBERG,
/** Snapshot in native Nessie Catalog format. */
NESSIE,
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ public Stream<Supplier<CompletionStage<SnapshotResponse>>> retrieveSnapshots(
try {
snapshotId = snapshotIdFromContent(c.getContent());
} catch (Exception e) {
e.printStackTrace();
// This silently handles the case when `c` refers neither to an Iceberg table nor a
// view.`
LOGGER.debug(
"Failed to retrieve snapshot ID for {}: {}", c.getContent(), e.toString());
return null;
}
return (Supplier<CompletionStage<SnapshotResponse>>)
Expand Down Expand Up @@ -520,13 +523,7 @@ private CompletionStage<MultiTableUpdate> applyIcebergTableCommitOperation(
Content updated =
icebergMetadataToContent(metadataJsonLocation, icebergMetadata, contentId);

ObjId snapshotId;
try {
snapshotId = snapshotIdFromContent(updated);
} catch (Exception e) {
e.printStackTrace();
return null;
}
ObjId snapshotId = snapshotIdFromContent(updated);
nessieSnapshot = nessieSnapshot.withId(objIdToNessieId(snapshotId));

SingleTableUpdate singleTableUpdate =
Expand Down Expand Up @@ -593,13 +590,7 @@ private CompletionStage<MultiTableUpdate> applyIcebergViewCommitOperation(
storeViewSnapshot(metadataJsonLocation, nessieSnapshot);
Content updated =
icebergMetadataToContent(metadataJsonLocation, icebergMetadata, contentId);
ObjId snapshotId;
try {
snapshotId = snapshotIdFromContent(updated);
} catch (Exception e) {
e.printStackTrace();
return null;
}
ObjId snapshotId = snapshotIdFromContent(updated);
nessieSnapshot = nessieSnapshot.withId(objIdToNessieId(snapshotId));

SingleTableUpdate singleTableUpdate =
Expand Down Expand Up @@ -669,15 +660,13 @@ static final class SingleTableUpdate {
}
}

private CompletionStage<NessieTableSnapshot> loadExistingTableSnapshot(Content content)
throws NessieContentNotFoundException {
private CompletionStage<NessieTableSnapshot> loadExistingTableSnapshot(Content content) {
ObjId snapshotId = snapshotIdFromContent(content);
return new IcebergStuff(objectIO, persist, tasksService, executor)
.retrieveIcebergSnapshot(snapshotId, content);
}

private CompletionStage<NessieViewSnapshot> loadExistingViewSnapshot(Content content)
throws NessieContentNotFoundException {
private CompletionStage<NessieViewSnapshot> loadExistingViewSnapshot(Content content) {
ObjId snapshotId = snapshotIdFromContent(content);
return new IcebergStuff(objectIO, persist, tasksService, executor)
.retrieveIcebergSnapshot(snapshotId, content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected CommitResponse executeCommitting(
throws Exception {
ContentKey contentKey = ContentKey.fromPathString(spec.getNamespace());

@SuppressWarnings("resource")
Content content =
applyReference(cli, spec, cli.mandatoryNessieApi().getContent())
.getSingle(contentKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void execute(@Nonnull BaseNessieCli cli, AssignReferenceCommandSpec spec)
default:
throw new IllegalArgumentException("Unknown reference type: " + spec.getRefType());
}
;

Reference assigned = api.assignReference().reference(ref).assignTo(toRef).assignAndGet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected CommitResponse executeCommitting(
throws Exception {
ContentKey contentKey = ContentKey.fromPathString(spec.getContentKey());

@SuppressWarnings("resource")
Content content =
applyReference(cli, spec, cli.mandatoryNessieApi().getContent())
.getSingle(contentKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected Stream<String> executeListing(BaseNessieCli cli, ListContentsCommandSp
}
}

@SuppressWarnings("resource")
GetEntriesBuilder entries = applyReference(cli, spec, cli.mandatoryNessieApi().getEntries());

if (filter != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected Stream<String> executeListing(BaseNessieCli cli, ListReferencesCommand
}
}

@SuppressWarnings("resource")
GetAllReferencesBuilder refs = cli.mandatoryNessieApi().getAllReferences().fetch(fetchOption);

if (filter != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ default List<CommandSpec> commandSpecs() {
// spec = null;
break;
}
;
}
if (spec != null) {
commandSpecs.add(spec);
Expand Down Expand Up @@ -162,7 +161,6 @@ default List<CommandSpec> commandSpecs() {
spec = null;
break;
}
;
if (spec != null) {
commandSpecs.add(spec);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void checkExtensions(Class<?> testClass) {
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
Optional<Version> version = nessieVersionFromContext(context);
if (!version.isPresent()) {
if (version.isEmpty()) {
if (isNessieMultiVersionTest(context)) {
return disabled("(not running via multi-nessie-version engine)");
}
Expand Down Expand Up @@ -158,7 +158,7 @@ Version populateNessieVersionAnnotatedFields(ExtensionContext context, Object in
checkExtensions(context.getRequiredTestClass());

Optional<Version> nessieVersion = nessieVersionFromContext(context);
if (!nessieVersion.isPresent()) {
if (nessieVersion.isEmpty()) {
return null;
}
Version version = nessieVersion.get();
Expand Down
Loading

0 comments on commit af04cbc

Please sign in to comment.