Skip to content

Commit

Permalink
Removed finally block that closes ably client, instead used try with …
Browse files Browse the repository at this point in the history
…resources
  • Loading branch information
sacOO7 committed Oct 17, 2024
1 parent a0354e5 commit 43f2eaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/src/main/java/io/ably/lib/realtime/Presence.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void implicitAttachOnSubscribe(CompletionListener completionListener) th
// RTP6e
if (!channel.attachOnSubscribeEnabled()) {
if (completionListener != null) {
String errorString = String.format(Locale.ROOT,
String errorString = String.format(
"Channel %s: attachOnSubscribe=false doesn't expect attach completion callback", channel.name);
Log.e(TAG, errorString);
ErrorInfo errorInfo = new ErrorInfo(errorString, 400,40000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1692,14 +1692,11 @@ public void presence_subscribe_without_implicit_attach() {
* @throws AblyException
*/
@Test
public void presence_subscribe_without_implicit_attach_and_completion_listener_throws_exception() {
public void presence_subscribe_without_implicit_attach_and_completion_listener_throws_exception() throws AblyException {
String ablyChannel = "subscribe_" + testParams.name;
AblyRealtime ably = null;
try {
ClientOptions option1 = createOptions(testVars.keys[0].keyStr);
option1.clientId = "client1";
ably = new AblyRealtime(option1);

ClientOptions option1 = createOptions(testVars.keys[0].keyStr);
option1.clientId = "client1";
try (AblyRealtime ably = new AblyRealtime(option1)) {
/* create a channel and set attachOnSubscribe to false */
final Channel channel = ably.channels.get(ablyChannel);
ChannelOptions chOpts = new ChannelOptions();
Expand All @@ -1720,9 +1717,6 @@ public void presence_subscribe_without_implicit_attach_and_completion_listener_t
} catch (AblyException e) {
e.printStackTrace();
fail("presence_subscribe_without_implicit_attach: Unexpected exception");
} finally {
if(ably != null)
ably.close();
}
}

Expand Down

0 comments on commit 43f2eaa

Please sign in to comment.