1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Use try-with-resources where possible

and make StanzaCollector implement AutoCloseable.
This commit is contained in:
Florian Schmaus 2019-02-04 09:36:37 +01:00
parent e98d42790a
commit 658fd08d20
10 changed files with 30 additions and 69 deletions

View file

@ -55,15 +55,10 @@ public abstract class AbstractSmackIntTest {
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
StanzaCollector.Configuration configuration = StanzaCollector.newConfiguration().setStanzaFilter(
filter).setSize(1);
StanzaCollector collector = connection.createStanzaCollector(configuration);
try {
try (StanzaCollector collector = connection.createStanzaCollector(configuration)) {
action.run();
collector.nextResultOrThrow(timeout);
}
finally {
collector.cancel();
}
}
@SuppressWarnings("ThreadPriorityCheck")