diff --git a/lib/src/main/java/io/ably/lib/realtime/Presence.java b/lib/src/main/java/io/ably/lib/realtime/Presence.java index 9a719db69..940b1d077 100644 --- a/lib/src/main/java/io/ably/lib/realtime/Presence.java +++ b/lib/src/main/java/io/ably/lib/realtime/Presence.java @@ -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); diff --git a/lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java b/lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java index f7b99c6c3..dee3e57d2 100644 --- a/lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java +++ b/lib/src/test/java/io/ably/lib/test/realtime/RealtimePresenceTest.java @@ -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(); @@ -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(); } }