Skip to content

Commit da7d431

Browse files
committed
chore: apply codereview suggestions
1 parent 31969a8 commit da7d431

8 files changed

Lines changed: 69 additions & 62 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/setup-java@v4
2020
with:
2121
java-version: '17'
22-
distribution: 'temurin'
22+
distribution: 'corretto'
2323

2424
- name: Set up Gradle
2525
uses: gradle/actions/setup-gradle@v3

java/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ tasks.register<Test>("testRestSuite") {
7979
}
8080
jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED")
8181
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
82+
jvmArgs("--add-opens", "java.base/java.net=ALL-UNNAMED")
83+
jvmArgs("--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED")
8284
beforeTest(closureOf<TestDescriptor> { logger.lifecycle("-> $this") })
8385
outputs.upToDateWhen { false }
8486
testLogging {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import io.ably.lib.util.Log;
5050
import io.ably.lib.util.ReconnectionStrategy;
5151
import io.ably.lib.util.StringUtils;
52+
import org.jetbrains.annotations.Blocking;
53+
import org.jetbrains.annotations.NonBlocking;
5254
import org.jetbrains.annotations.Nullable;
5355

5456
/**
@@ -1318,7 +1320,7 @@ public void deleteMessageAsync(Message message, Callback<UpdateDeleteResult> cal
13181320
}
13191321

13201322
/**
1321-
* Appends message text to the end of the message.
1323+
* Appends message text to the end of the message data.
13221324
*
13231325
* @param message A {@link Message} object containing the serial identifier and data to append.
13241326
* @param operation operation details such as clientId, description, or metadata
@@ -1378,6 +1380,7 @@ public void appendMessageAsync(Message message, Callback<UpdateDeleteResult> cal
13781380
* representing all versions of the message.
13791381
* @throws AblyException If the versions cannot be retrieved.
13801382
*/
1383+
@Blocking
13811384
public PaginatedResult<Message> getMessageVersions(String serial, Param[] params) throws AblyException {
13821385
return messageEditsMixin.getMessageVersions(ably.http, serial, params);
13831386
}
@@ -1389,6 +1392,7 @@ public PaginatedResult<Message> getMessageVersions(String serial, Param[] params
13891392
* @param params Query parameters for filtering or pagination.
13901393
* @param callback A callback to handle the result asynchronously.
13911394
*/
1395+
@NonBlocking
13921396
public void getMessageVersionsAsync(String serial, Param[] params, Callback<AsyncPaginatedResult<Message>> callback) throws AblyException {
13931397
messageEditsMixin.getMessageVersionsAsync(ably.http, serial, params, callback);
13941398
}

lib/src/main/java/io/ably/lib/rest/ChannelBase.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import io.ably.lib.types.PresenceSerializer;
2020
import io.ably.lib.types.UpdateDeleteResult;
2121
import io.ably.lib.util.Crypto;
22+
import org.jetbrains.annotations.Blocking;
23+
import org.jetbrains.annotations.NonBlocking;
2224

2325
/**
2426
* A class representing a Channel in the Ably REST API.
@@ -327,6 +329,7 @@ private BasePaginatedQuery.ResultRequest<PresenceMessage> historyImpl(Http http,
327329
* @return A {@link Message} object representing the latest version of the message.
328330
* @throws AblyException If the message cannot be retrieved or does not exist.
329331
*/
332+
@Blocking
330333
public Message getMessage(String serial) throws AblyException {
331334
return messageEditsMixin.getMessage(ably.http, serial);
332335
}
@@ -339,6 +342,7 @@ public Message getMessage(String serial) throws AblyException {
339342
* <p>
340343
* This callback is invoked on a background thread.
341344
*/
345+
@NonBlocking
342346
public void getMessageAsync(String serial, Callback<Message> callback) {
343347
messageEditsMixin.getMessageAsync(ably.http, serial, callback);
344348
}
@@ -355,6 +359,7 @@ public void getMessageAsync(String serial, Callback<Message> callback) {
355359
* @throws AblyException If the update operation fails.
356360
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
357361
*/
362+
@Blocking
358363
public UpdateDeleteResult updateMessage(Message message, MessageOperation operation) throws AblyException {
359364
return messageEditsMixin.updateMessage(ably.http, message, operation);
360365
}
@@ -370,6 +375,7 @@ public UpdateDeleteResult updateMessage(Message message, MessageOperation operat
370375
* @throws AblyException If the update operation fails.
371376
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
372377
*/
378+
@Blocking
373379
public UpdateDeleteResult updateMessage(Message message) throws AblyException {
374380
return updateMessage(message, null);
375381
}
@@ -383,6 +389,7 @@ public UpdateDeleteResult updateMessage(Message message) throws AblyException {
383389
* <p>
384390
* This callback is invoked on a background thread.
385391
*/
392+
@NonBlocking
386393
public void updateMessageAsync(Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
387394
messageEditsMixin.updateMessageAsync(ably.http, message, operation, callback);
388395
}
@@ -395,6 +402,7 @@ public void updateMessageAsync(Message message, MessageOperation operation, Call
395402
* <p>
396403
* This callback is invoked on a background thread.
397404
*/
405+
@NonBlocking
398406
public void updateMessageAsync(Message message, Callback<UpdateDeleteResult> callback) {
399407
updateMessageAsync(message, null, callback);
400408
}
@@ -411,6 +419,7 @@ public void updateMessageAsync(Message message, Callback<UpdateDeleteResult> cal
411419
* @throws AblyException If the delete operation fails.
412420
* @return A {@link UpdateDeleteResult} containing the deleted message version serial.
413421
*/
422+
@Blocking
414423
public UpdateDeleteResult deleteMessage(Message message, MessageOperation operation) throws AblyException {
415424
return messageEditsMixin.deleteMessage(ably.http, message, operation);
416425
}
@@ -426,6 +435,7 @@ public UpdateDeleteResult deleteMessage(Message message, MessageOperation operat
426435
* @throws AblyException If the delete operation fails.
427436
* @return A {@link UpdateDeleteResult} containing the deleted message version serial.
428437
*/
438+
@Blocking
429439
public UpdateDeleteResult deleteMessage(Message message) throws AblyException {
430440
return deleteMessage(message, null);
431441
}
@@ -439,6 +449,7 @@ public UpdateDeleteResult deleteMessage(Message message) throws AblyException {
439449
* <p>
440450
* This callback is invoked on a background thread.
441451
*/
452+
@NonBlocking
442453
public void deleteMessageAsync(Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
443454
messageEditsMixin.deleteMessageAsync(ably.http, message, operation, callback);
444455
}
@@ -451,6 +462,7 @@ public void deleteMessageAsync(Message message, MessageOperation operation, Call
451462
* <p>
452463
* This callback is invoked on a background thread.
453464
*/
465+
@NonBlocking
454466
public void deleteMessageAsync(Message message, Callback<UpdateDeleteResult> callback) {
455467
deleteMessageAsync(message, null, callback);
456468
}
@@ -463,6 +475,7 @@ public void deleteMessageAsync(Message message, Callback<UpdateDeleteResult> cal
463475
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
464476
* @throws AblyException If the append operation fails.
465477
*/
478+
@Blocking
466479
public UpdateDeleteResult appendMessage(Message message, MessageOperation operation) throws AblyException {
467480
return messageEditsMixin.appendMessage(ably.http, message, operation);
468481
}
@@ -474,6 +487,7 @@ public UpdateDeleteResult appendMessage(Message message, MessageOperation operat
474487
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
475488
* @throws AblyException If the append operation fails.
476489
*/
490+
@Blocking
477491
public UpdateDeleteResult appendMessage(Message message) throws AblyException {
478492
return appendMessage(message, null);
479493
}
@@ -487,6 +501,7 @@ public UpdateDeleteResult appendMessage(Message message) throws AblyException {
487501
* <p>
488502
* This callback is invoked on a background thread.
489503
*/
504+
@NonBlocking
490505
public void appendMessageAsync(Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
491506
messageEditsMixin.appendMessageAsync(ably.http, message, operation, callback);
492507
}
@@ -499,6 +514,7 @@ public void appendMessageAsync(Message message, MessageOperation operation, Call
499514
* <p>
500515
* This callback is invoked on a background thread.
501516
*/
517+
@NonBlocking
502518
public void appendMessageAsync(Message message, Callback<UpdateDeleteResult> callback) {
503519
appendMessageAsync(message, null, callback);
504520
}
@@ -516,6 +532,7 @@ public void appendMessageAsync(Message message, Callback<UpdateDeleteResult> cal
516532
* representing all versions of the message.
517533
* @throws AblyException If the versions cannot be retrieved.
518534
*/
535+
@Blocking
519536
public PaginatedResult<Message> getMessageVersions(String serial, Param[] params) throws AblyException {
520537
return messageEditsMixin.getMessageVersions(ably.http, serial, params);
521538
}
@@ -527,6 +544,7 @@ public PaginatedResult<Message> getMessageVersions(String serial, Param[] params
527544
* @param params Query parameters for filtering or pagination.
528545
* @param callback A callback to handle the result asynchronously.
529546
*/
547+
@NonBlocking
530548
public void getMessageVersionsAsync(String serial, Param[] params, Callback<AsyncPaginatedResult<Message>> callback) throws AblyException {
531549
messageEditsMixin.getMessageVersionsAsync(ably.http, serial, params, callback);
532550
}

lib/src/main/java/io/ably/lib/rest/MessageEditsMixin.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import io.ably.lib.types.Param;
2020
import io.ably.lib.types.UpdateDeleteResult;
2121
import io.ably.lib.util.Crypto;
22+
import org.jetbrains.annotations.Blocking;
23+
import org.jetbrains.annotations.NonBlocking;
2224

2325
public class MessageEditsMixin {
2426

@@ -47,6 +49,7 @@ public MessageEditsMixin(String basePath, ClientOptions clientOptions, ChannelOp
4749
* @return A {@link Message} object representing the latest version of the message.
4850
* @throws AblyException If the message cannot be retrieved or does not exist.
4951
*/
52+
@Blocking
5053
public Message getMessage(Http http, String serial) throws AblyException {
5154
return getMessageImpl(http, serial).sync();
5255
}
@@ -59,6 +62,7 @@ public Message getMessage(Http http, String serial) throws AblyException {
5962
* <p>
6063
* This callback is invoked on a background thread.
6164
*/
65+
@NonBlocking
6266
public void getMessageAsync(Http http, String serial, Callback<Message> callback) {
6367
getMessageImpl(http, serial).async(callback);
6468
}
@@ -96,6 +100,7 @@ private Http.Request<Message> getMessageImpl(Http http, String serial) {
96100
*
97101
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
98102
*/
103+
@Blocking
99104
public UpdateDeleteResult updateMessage(Http http, Message message, MessageOperation operation) throws AblyException {
100105
return updateMessageImpl(http, message, operation, MessageAction.MESSAGE_UPDATE).sync();
101106
}
@@ -108,6 +113,7 @@ public UpdateDeleteResult updateMessage(Http http, Message message, MessageOpera
108113
* <p>
109114
* This listener is invoked on a background thread.
110115
*/
116+
@NonBlocking
111117
public void updateMessageAsync(Http http, Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
112118
updateMessageImpl(http, message, operation, MessageAction.MESSAGE_UPDATE).async(callback);
113119
}
@@ -124,6 +130,7 @@ public void updateMessageAsync(Http http, Message message, MessageOperation oper
124130
*
125131
* @return A {@link UpdateDeleteResult} containing the deleted message version serial.
126132
*/
133+
@Blocking
127134
public UpdateDeleteResult deleteMessage(Http http, Message message, MessageOperation operation) throws AblyException {
128135
return updateMessageImpl(http, message, operation, MessageAction.MESSAGE_DELETE).sync();
129136
}
@@ -136,6 +143,7 @@ public UpdateDeleteResult deleteMessage(Http http, Message message, MessageOpera
136143
* <p>
137144
* This listener is invoked on a background thread.
138145
*/
146+
@NonBlocking
139147
public void deleteMessageAsync(Http http, Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
140148
updateMessageImpl(http, message, operation, MessageAction.MESSAGE_DELETE).async(callback);
141149
}
@@ -147,6 +155,7 @@ public void deleteMessageAsync(Http http, Message message, MessageOperation oper
147155
* @param operation operation details such as clientId, description, or metadata
148156
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
149157
*/
158+
@Blocking
150159
public UpdateDeleteResult appendMessage(Http http, Message message, MessageOperation operation) throws AblyException {
151160
return updateMessageImpl(http, message, operation, MessageAction.MESSAGE_APPEND).sync();
152161
}
@@ -160,6 +169,7 @@ public UpdateDeleteResult appendMessage(Http http, Message message, MessageOpera
160169
* <p>
161170
* This listener is invoked on a background thread.
162171
*/
172+
@NonBlocking
163173
public void appendMessageAsync(Http http, Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
164174
updateMessageImpl(http, message, operation, MessageAction.MESSAGE_APPEND).async(callback);
165175
}
@@ -197,7 +207,7 @@ private Http.Request<UpdateDeleteResult> updateMessageImpl(Http http, Message me
197207
if (error != null) throw AblyException.fromErrorInfo(error);
198208
UpdateDeleteResult[] results = bodyHandler.handleResponseBody(response.contentType, response.body);
199209
if (results != null && results.length > 0) return results[0];
200-
throw AblyException.fromErrorInfo(new ErrorInfo("No versionSerial in the update message response", 500, 50000));
210+
throw AblyException.fromErrorInfo(new ErrorInfo("No versionSerial in the response", 500, 50000));
201211
},
202212
true,
203213
callback);
@@ -217,6 +227,7 @@ private Http.Request<UpdateDeleteResult> updateMessageImpl(Http http, Message me
217227
* representing all versions of the message.
218228
* @throws AblyException If the versions cannot be retrieved.
219229
*/
230+
@Blocking
220231
public PaginatedResult<Message> getMessageVersions(Http http, String serial, Param[] params) throws AblyException {
221232
return getMessageVersionsImpl(http, serial, params).sync();
222233
}
@@ -228,6 +239,7 @@ public PaginatedResult<Message> getMessageVersions(Http http, String serial, Par
228239
* @param params Query parameters for filtering or pagination.
229240
* @param callback A callback to handle the result asynchronously.
230241
*/
242+
@NonBlocking
231243
public void getMessageVersionsAsync(Http http, String serial, Param[] params, Callback<AsyncPaginatedResult<Message>> callback) throws AblyException {
232244
getMessageVersionsImpl(http, serial, params).async(callback);
233245
}

lib/src/main/java/io/ably/lib/types/UpdateDeleteResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public UpdateDeleteResult(@Nullable String versionSerial) {
2525
this.versionSerial = versionSerial;
2626
}
2727

28-
public static UpdateDeleteResult readFromJson(byte[] packed) throws MessageDecodeException {
28+
private static UpdateDeleteResult readFromJson(byte[] packed) throws MessageDecodeException {
2929
return Serialisation.gson.fromJson(new String(packed), UpdateDeleteResult.class);
3030
}
3131

32-
public static UpdateDeleteResult readMsgpack(byte[] packed) throws AblyException {
32+
private static UpdateDeleteResult readMsgpack(byte[] packed) throws AblyException {
3333
try {
3434
MessageUnpacker unpacker = Serialisation.msgpackUnpackerConfig.newUnpacker(packed);
3535
return readMsgpack(unpacker);
@@ -38,7 +38,7 @@ public static UpdateDeleteResult readMsgpack(byte[] packed) throws AblyException
3838
}
3939
}
4040

41-
public static UpdateDeleteResult readMsgpack(MessageUnpacker unpacker) throws IOException {
41+
private static UpdateDeleteResult readMsgpack(MessageUnpacker unpacker) throws IOException {
4242
int fieldCount = unpacker.unpackMapHeader();
4343
String versionSerial = null;
4444
for (int i = 0; i < fieldCount; i++) {

lib/src/main/java/io/ably/lib/util/Listeners.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)