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 @@ -31,10 +31,13 @@
import jakarta.ws.rs.client.Invocation.Builder;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status.Family;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.http.HttpTimeoutException;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeoutException;

abstract class AbstractRequestExecutor implements RequestExecutor {

Expand Down Expand Up @@ -79,15 +82,27 @@ private WorkflowModel doRequest(
.application()
.modelFactory()
.fromAny(response.readEntity(converter.responseType()));
} catch (ProcessingException | IllegalStateException ex) {
} catch (ProcessingException ex) {
throw new WorkflowException(
WorkflowError.communication(Errors.DATA.status(), task, ex).build(), ex);
WorkflowError.communication(errorCodeFromException(ex.getCause()), task, ex).build(), ex);
Comment thread
fjtirado marked this conversation as resolved.
} catch (WebApplicationException ex) {
throw new WorkflowException(
WorkflowError.communication(ex.getResponse().getStatus(), task, ex).build(), ex);
}
}

protected int errorCodeFromException(Throwable ex) {
while (ex != null) {
if (ex instanceof TimeoutException
|| ex instanceof SocketTimeoutException
|| ex instanceof HttpTimeoutException) {
return Errors.TIMEOUT.status();
Comment thread
fjtirado marked this conversation as resolved.
}
ex = ex.getCause();
}
return Errors.COMMUNICATION.status();
}

private void validateStatus(TaskContext task, Response response, HttpModelConverter converter) {
Family statusFamily = response.getStatusInfo().getFamily();
if (statusFamily != SUCCESSFUL && (!this.redirect || statusFamily != REDIRECTION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ public String toString() {
}
}

// ---- Standard catalog (defaults are conventional HTTP mappings; override if you prefer) ----
public static final Standard RUNTIME = new Standard("runtime", 500);
public static final Standard COMMUNICATION = new Standard("communication", 502);
public static final Standard COMMUNICATION = new Standard("communication", 500);
Comment thread
fjtirado marked this conversation as resolved.
Comment thread
fjtirado marked this conversation as resolved.
Comment thread
fjtirado marked this conversation as resolved.
public static final Standard AUTHENTICATION = new Standard("authentication", 401);
public static final Standard AUTHORIZATION = new Standard("authorization", 403);
public static final Standard DATA = new Standard("data", 422);
Expand Down
Loading