1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 18:48:00 +01:00

Merge pull request #529 from Flowdalic/fix-sd-memleak

[disco] Fix memory leak in ServiceDiscoveryManager
This commit is contained in:
Florian Schmaus 2022-05-26 18:11:54 +02:00 committed by GitHub
commit c9af6576c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2003-2007 Jive Software, 2018-2020 Florian Schmaus. * Copyright 2003-2007 Jive Software, 2018-2022 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -933,6 +933,10 @@ public final class ServiceDiscoveryManager extends Manager {
* Notify the {@link EntityCapabilitiesChangedListener} about changed capabilities. * Notify the {@link EntityCapabilitiesChangedListener} about changed capabilities.
*/ */
private synchronized void renewEntityCapsVersion() { private synchronized void renewEntityCapsVersion() {
if (entityCapabilitiesChangedListeners.isEmpty()) {
return;
}
renewEntityCapsRequested++; renewEntityCapsRequested++;
if (renewEntityCapsScheduledAction != null) { if (renewEntityCapsScheduledAction != null) {
boolean canceled = renewEntityCapsScheduledAction.cancel(); boolean canceled = renewEntityCapsScheduledAction.cancel();
@ -941,9 +945,12 @@ public final class ServiceDiscoveryManager extends Manager {
} }
} }
final XMPPConnection connection = connection();
renewEntityCapsScheduledAction = scheduleBlocking(() -> { renewEntityCapsScheduledAction = scheduleBlocking(() -> {
final XMPPConnection connection = connection();
if (connection == null) {
return;
}
renewEntityCapsPerformed.incrementAndGet(); renewEntityCapsPerformed.incrementAndGet();
DiscoverInfoBuilder discoverInfoBuilder = DiscoverInfo.builder("synthetized-disco-info-response") DiscoverInfoBuilder discoverInfoBuilder = DiscoverInfo.builder("synthetized-disco-info-response")