From 5d65507584d6c66f457829d9e88d2be0864b3cfe Mon Sep 17 00:00:00 2001 From: lolodomo Date: Fri, 5 May 2023 21:49:54 +0200 Subject: [PATCH] [googlestt] Dispose oAuth2 service (#14936) * [googlestt] Dispose oAuth2 service Related to #14818 Signed-off-by: Laurent Garnier --- .../voice/googlestt/internal/GoogleSTTService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java b/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java index 7254e68df..120460921 100644 --- a/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java +++ b/bundles/org.openhab.voice.googlestt/src/main/java/org/openhab/voice/googlestt/internal/GoogleSTTService.java @@ -48,6 +48,7 @@ import org.osgi.framework.Constants; 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; @@ -117,6 +118,14 @@ public class GoogleSTTService implements STTService { updateConfig(); } + @Deactivate + protected void dispose() { + if (oAuthService != null) { + oAuthFactory.ungetOAuthService(SERVICE_PID); + oAuthService = null; + } + } + @Override public String getId() { return SERVICE_ID; @@ -157,6 +166,10 @@ public class GoogleSTTService implements STTService { } 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()) {