readOrEmpty should throw the NotSavedException

This commit is contained in:
finn 2022-08-22 15:42:02 -07:00
parent e62fc9ee06
commit b6e9abb818

View file

@ -1,4 +1,4 @@
From ae19ed8b15251adae911868ffe570e5608bc2eef Mon Sep 17 00:00:00 2001
From b58a6a7defbc7fa876bb980ee45c5cbbe49ed40e Mon Sep 17 00:00:00 2001
From: signald <nobody@signald.org>
Date: Thu, 16 Jun 2022 13:04:00 -0700
Subject: [PATCH] update build files and provide a way for the websocket
@ -10,9 +10,9 @@ Subject: [PATCH] update build files and provide a way for the websocket
gradle/verification-metadata.xml | 13 ++++++++-----
service/build.gradle | 19 +++++++++----------
.../signalservice/api/NotSavedException.java | 4 ++++
.../signalservice/api/SignalWebSocket.java | 13 ++++++++++---
.../signalservice/api/SignalWebSocket.java | 16 ++++++++++++----
settings.gradle | 1 -
7 files changed, 35 insertions(+), 35 deletions(-)
7 files changed, 37 insertions(+), 36 deletions(-)
create mode 100644 service/src/main/java/org/whispersystems/signalservice/api/NotSavedException.java
diff --git a/build.gradle b/build.gradle
@ -155,10 +155,16 @@ index 00000000..05d77d1f
+public class NotSavedException extends Exception {
+}
diff --git a/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java b/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java
index 5a98f3c4..dff24940 100644
index 5a98f3c4..6ae9d72e 100644
--- a/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java
+++ b/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java
@@ -243,6 +243,7 @@ public final class SignalWebSocket {
@@ -238,11 +238,12 @@ public final class SignalWebSocket {
*/
@SuppressWarnings("DuplicateThrows")
public Optional<SignalServiceEnvelope> readOrEmpty(long timeout, MessageReceivedCallback callback)
- throws TimeoutException, WebSocketUnavailableException, IOException
+ throws TimeoutException, WebSocketUnavailableException, IOException, NotSavedException
{
while (true) {
WebSocketRequestMessage request = getWebSocket().readRequest(timeout);
WebSocketResponseMessage response = createWebSocketResponse(request);
@ -166,7 +172,7 @@ index 5a98f3c4..dff24940 100644
try {
if (isSignalServiceEnvelope(request)) {
Optional<String> timestampHeader = findHeader(request);
@@ -258,13 +259,19 @@ public final class SignalWebSocket {
@@ -258,13 +259,20 @@ public final class SignalWebSocket {
SignalServiceEnvelope envelope = new SignalServiceEnvelope(request.getBody().toByteArray(), timestamp);
@ -175,6 +181,7 @@ index 5a98f3c4..dff24940 100644
+ callback.onMessage(envelope);
+ } catch (NotSavedException e) {
+ sendResponse = false;
+ throw e;
+ }
return Optional.of(envelope);
} else if (isSocketEmptyRequest(request)) {
@ -188,7 +195,7 @@ index 5a98f3c4..dff24940 100644
}
}
}
@@ -315,6 +322,6 @@ public final class SignalWebSocket {
@@ -315,6 +323,6 @@ public final class SignalWebSocket {
* received.
*/
public interface MessageReceivedCallback {