From 76ac9af0d656b516af3e0f7d74e5ebb57b4e3f00 Mon Sep 17 00:00:00 2001 From: florian <60937022+cdr-chakotay@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:18:58 +0200 Subject: [PATCH] Remove Debug Output from EventsourceRunnable --- .../java/com/transloadit/sdk/EventsourceRunnable.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/transloadit/sdk/EventsourceRunnable.java b/src/main/java/com/transloadit/sdk/EventsourceRunnable.java index 9fef8a9..bb200d7 100644 --- a/src/main/java/com/transloadit/sdk/EventsourceRunnable.java +++ b/src/main/java/com/transloadit/sdk/EventsourceRunnable.java @@ -109,7 +109,6 @@ protected void handleMessageEvent(MessageEvent messageEvent) { String eventName = messageEvent.getEventName(); String data = messageEvent.getData(); - System.out.println("Event: " + eventName + "\t" + "Data: " + data); // Check if the event is a message event without if (eventName.equals("message")) { switch (data) { @@ -130,7 +129,8 @@ protected void handleMessageEvent(MessageEvent messageEvent) { assemblyListener.onAssemblyUploadFinished(); break; default: - System.out.printf("Unknown message: %s\n", data); + LocalOperationException e = new LocalOperationException("Unknown SSE message: " + data); + assemblyListener.onError(e); } } else { switch (eventName) { @@ -156,12 +156,14 @@ protected void handleMessageEvent(MessageEvent messageEvent) { case "assembly_execution_progress": JSONObject executionProgress = new JSONObject(data); double overallProgress; + // Address the case where the progress_combined key is not present in the JSON object try { overallProgress = executionProgress.getDouble("progress_combined"); } catch (Exception e) { overallProgress = 0; } + // Address the case where the progress_per_original_file key is not present in the JSON object JSONObject progressPerOriginalFile; try { progressPerOriginalFile = executionProgress.getJSONObject("progress_per_original_file"); @@ -172,7 +174,8 @@ protected void handleMessageEvent(MessageEvent messageEvent) { assemblyListener.onAssemblyProgress(overallProgress, progressPerOriginalFile); break; default: - System.out.printf("Unknown message: %s\n", eventName); + LocalOperationException e = new LocalOperationException("Unknown SSE message: " + data); + assemblyListener.onError(e); } }