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
1 change: 1 addition & 0 deletions changes/fix_null-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null error list for Import actions causing unrenderable actions
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ protected Response execute(SubmitAction action, Optional<String> user) {
Preference.ALLOW_BULK) {
@Override
protected Response execute(VidarrAction action, Optional<String> user) {
// JDK 21: use pattern-matching switch
if (action instanceof SubmitAction) {
final Optional<RunState> result = ((SubmitAction) action).state.reattempt();
result.ifPresent(s -> ((SubmitAction) action).state = s);
return result.isPresent() ? Response.RESET : Response.IGNORED;
} else if (action instanceof ImportAction) {
final Optional<ImportState> result = ((ImportAction) action).state.reattempt();
result.ifPresent(s -> ((ImportAction) action).state = s);
return result.isPresent() ? Response.RESET : Response.IGNORED;
}
return Response.IGNORED;
return switch (action) {
case SubmitAction submitAction:
final Optional<RunState> submitReattempt = submitAction.state.reattempt();
submitReattempt.ifPresent(s -> submitAction.state = s);
yield submitReattempt.isPresent() ? Response.RESET : Response.IGNORED;
case ImportAction importAction:
final Optional<ImportState> importReattempt = importAction.state.reattempt();
importReattempt.ifPresent(s -> importAction.state = s);
yield importReattempt.isPresent() ? Response.RESET : Response.IGNORED;
default:
yield Response.IGNORED;
};
}
};
static final ActionCommand<VidarrAction> RESET =
Expand All @@ -74,16 +75,19 @@ protected Response execute(VidarrAction action, Optional<String> user) {
Preference.ALLOW_BULK) {
@Override
protected Response execute(VidarrAction action, Optional<String> user) {
// JDK 21: use pattern-matching switch
if (action instanceof SubmitAction) {
((SubmitAction) action).state = new RunStateAttemptSubmit();
} else if (action instanceof ImportAction) {
((ImportAction) action).state = new ImportStateAttemptSubmit();
}

return Response.RESET;
return switch (action) {
case SubmitAction submitAction:
submitAction.state = new RunStateAttemptSubmit();
yield Response.RESET;
case ImportAction importAction:
importAction.state = new ImportStateAttemptSubmit();
yield Response.RESET;
default:
yield Response.RESET;
};
}
};

static final ActionCommand<SubmitAction> RETRY_PROVISION_OUT =
new ActionCommand<>(
SubmitAction.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public boolean equals(Object other) {
if (this == other) return true;
if (null == other || getClass() != other.getClass()) return false;
ImportAction o = (ImportAction) other;
return stale == o.stale && Objects.equals(this.request, o.request);
return stale == o.stale && this.request.equalsIgnoreAttempt(o.request);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class ImportStateAttemptSubmit extends ImportState {
private int retryMinutes = 5;
List<String> errors = null;
List<String> errors = List.of();
private final int attempt;

public ImportStateAttemptSubmit(int attempt) {
Expand Down Expand Up @@ -77,6 +77,7 @@ public PerformResult perform(
case 500:
{ // Internal Server Error
retryMinutes = Math.min(retryMinutes * 2, 60);
errors = List.of(response.body());
return new PerformResult(errors, ActionState.FAILED, this);
}
case 507:
Expand Down
Loading