Skip to content

Commit

Permalink
[googlestt] Dispose oAuth2 service (openhab#14936)
Browse files Browse the repository at this point in the history
* [googlestt] Dispose oAuth2 service

Related to openhab#14818

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
lolodomo authored and austvik committed Mar 27, 2024
1 parent 69a60b5 commit c63ef38
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
Expand Down Expand Up @@ -117,6 +118,14 @@ protected void modified(Map<String, Object> config) {
updateConfig();
}

@Deactivate
protected void dispose() {
if (oAuthService != null) {
oAuthFactory.ungetOAuthService(SERVICE_PID);
oAuthService = null;
}
}

@Override
public String getId() {
return SERVICE_ID;
Expand Down Expand Up @@ -157,6 +166,10 @@ public void abort() {
}

private void updateConfig() {
if (oAuthService != null) {
oAuthFactory.ungetOAuthService(SERVICE_PID);
oAuthService = null;
}
String clientId = this.config.clientId;
String clientSecret = this.config.clientSecret;
if (!clientId.isBlank() && !clientSecret.isBlank()) {
Expand Down

0 comments on commit c63ef38

Please sign in to comment.