Skip to content

Commit

Permalink
Also better response on error
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Mar 31, 2021
1 parent defa85a commit cbab82c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,23 @@ public final PrintJobResult call() throws Exception {
null :
createResult(fileName, fileExtension, mimeType);
} catch (Exception e) {
String canceledText = "";
if (Thread.currentThread().isInterrupted()) {
canceledText = "(canceled) ";
LOGGER.info(
"Print job canceled {}\n{}",
this.entry.getRequestData(), this.entry.getReferenceId()
);
this.metricRegistry.counter(getClass().getName() + ".canceled").inc();
jobTracker.onJobCancel();
} else {
LOGGER.warn(
"Error executing print job {}\n{}",
this.entry.getRequestData(), this.entry.getReferenceId(), e
);
this.metricRegistry.counter(getClass().getName() + ".error").inc();
jobTracker.onJobError();
}
deleteReport();
maybeSendError(mapPrinter.getConfiguration(), e);
LOGGER.warn("Error executing print job {} {}\n{}",
this.entry.getRequestData(), canceledText, this.entry.getReferenceId(), e);
throw e;
} finally {
final long totalTimeMS = System.currentTimeMillis() - entry.getStartTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,16 @@ private void waitForFailure(String ref) throws IOException, ServletException, In
servlet.getReport(ref, false, servletGetReportResponse);
final int status = servletGetReportResponse.getStatus();
if (status == HttpStatus.ACCEPTED.value()) {
// still processing
Thread.sleep(500);
} else if (status == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
return;
if (servletGetReportResponse.getContentAsString().startsWith("Error while processing request:")) {
return;
} else {
// Still processing
Thread.sleep(500);
}
} else {
fail(status + " was not one of the expected response codes. Expected: 500 or 202");
fail(
status + " was not one of the expected response codes. Expected: 200"
);
}
}
}
Expand Down

0 comments on commit cbab82c

Please sign in to comment.