Skip to content

Commit 47b958f

Browse files
committed
chore: apply codereview suggestions
1 parent 99a2c94 commit 47b958f

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎lib/src/main/java/io/ably/lib/realtime/ChannelBase.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,13 @@ private void updateDeleteImpl(
13931393

13941394
ProtocolMessage msg = new ProtocolMessage(Action.message, this.name);
13951395
msg.messages = new Message[] { updatedMessage };
1396-
connectionManager.send(msg, queueMessages, Listeners.toPublishResultListener(listener));
1396+
try {
1397+
connectionManager.send(msg, queueMessages, Listeners.toPublishResultListener(listener));
1398+
} catch (AblyException e) {
1399+
if (listener != null) {
1400+
listener.onError(e.errorInfo);
1401+
}
1402+
}
13971403
}
13981404

13991405
/**

‎lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelMessageEditTest.java‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import static org.junit.Assert.assertTrue;
3232

3333
/**
34-
* Tests for REST channel message edit and delete operations
34+
* Tests for realtime channel message edit and delete operations
3535
*/
3636
public class RealtimeChannelMessageEditTest extends ParameterizedTest {
3737

@@ -387,16 +387,16 @@ public void appendMessage_checkUpdatedData() throws Exception {
387387
Message retrieved = waitForUpdatedMessageAppear(channel, serial);
388388
assertEquals("Expected updated data in history", "Initial dataAppend data", retrieved.data);
389389
assertEquals("Expected MESSAGE_UPDATE action in history", MessageAction.MESSAGE_UPDATE, retrieved.action);
390-
assertEquals("Expected MESSAGE_APPEND action through realtime",MessageAction.MESSAGE_APPEND, appendWaiter.result.action);
391-
assertEquals("Expected delta through realtime","Append data", appendWaiter.result.data);
390+
assertEquals("Expected MESSAGE_APPEND action through realtime", MessageAction.MESSAGE_APPEND, appendWaiter.result.action);
391+
assertEquals("Expected delta through realtime", "Append data", appendWaiter.result.data);
392392

393393
}
394394

395395
private PaginatedResult<Message> waitForMessageAppearInVersionHistory(Channel channel, String serial, Param[] params, Predicate<Message[]> predicate) throws Exception {
396396
long timeout = System.currentTimeMillis() + 5_000;
397397
while (true) {
398398
PaginatedResult<Message> history = channel.getMessageVersions(serial, params);
399-
if (history.items().length > 0 && predicate.test(history.items()) || System.currentTimeMillis() > timeout)
399+
if ((history.items().length > 0 && predicate.test(history.items())) || System.currentTimeMillis() > timeout)
400400
return history;
401401
Thread.sleep(200);
402402
}
@@ -419,7 +419,10 @@ private Message waitForUpdatedMessageAppear(Channel channel, String serial) thro
419419
if ((message != null && message.action == MessageAction.MESSAGE_UPDATE) || System.currentTimeMillis() > timeout)
420420
return message;
421421
Thread.sleep(200);
422-
} catch (Exception e) {}
422+
} catch (AblyException e) {
423+
// skip not found errors
424+
if (e.errorInfo.statusCode != 404) throw e;
425+
}
423426
}
424427
}
425428

@@ -431,7 +434,10 @@ private Message waitForDeletedMessageAppear(Channel channel, String serial) thro
431434
if ((message != null && message.action == MessageAction.MESSAGE_DELETE) || System.currentTimeMillis() > timeout)
432435
return message;
433436
Thread.sleep(200);
434-
} catch (Exception e) {}
437+
} catch (AblyException e) {
438+
// skip not found errors
439+
if (e.errorInfo.statusCode != 404) throw e;
440+
}
435441
}
436442
}
437443
}

0 commit comments

Comments
 (0)