Skip to content

Commit

Permalink
perform client actions in new thread to allow pings during long runni…
Browse files Browse the repository at this point in the history
…ng processes (qzind#1177)
  • Loading branch information
akberenz authored Oct 4, 2023
1 parent cc4454e commit ee94ad6
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/qz/ws/PrintSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,34 @@ public void onMessage(Session session, Reader reader) throws IOException {
}
}

processMessage(session, json, connection, request);
}
catch(UnsatisfiedLinkError | LoaderException e) {
log.error("A component is missing or broken, preventing this feature from working", e);
sendError(session, UID, "Sorry, this feature is unavailable at this time");
//spawn thread to prevent long processes from blocking
final String tUID = UID;
new Thread(() -> {
try {
processMessage(session, json, connection, request);
}
catch(UnsatisfiedLinkError | LoaderException e) {
log.error("A component is missing or broken, preventing this feature from working", e);
sendError(session, tUID, "Sorry, this feature is unavailable at this time");
}
catch(JSONException e) {
log.error("Bad JSON: {}", e.getMessage());
sendError(session, tUID, e);
}
catch(InvalidPathException | FileSystemException e) {
log.error("FileIO exception occurred", e);
sendError(session, tUID, String.format("FileIO exception occurred: %s: %s", e.getClass().getSimpleName(), e.getMessage()));
}
catch(Exception e) {
log.error("Problem processing message", e);
sendError(session, tUID, e);
}
}).start();
}
catch(JSONException e) {
log.error("Bad JSON: {}", e.getMessage());
sendError(session, UID, e);
}
catch(InvalidPathException | FileSystemException e) {
log.error("FileIO exception occurred", e);
sendError(session, UID, String.format("FileIO exception occurred: %s: %s", e.getClass().getSimpleName(), e.getMessage()));
}
catch(Exception e) {
log.error("Problem processing message", e);
sendError(session, UID, e);
Expand Down

0 comments on commit ee94ad6

Please sign in to comment.