private @Nullable List<Event> eventHistory;
private @NonNullByDefault({}) OAuthClientService oAuthClientService;
- private @NonNullByDefault({}) String oAuthServiceHandleId;
+ private @Nullable String oAuthServiceHandleId;
private @NonNullByDefault({}) HomeConnectApiClient apiClient;
private @NonNullByDefault({}) HomeConnectEventSourceClient eventSourceClient;
}
}
+ @Override
+ public void handleRemoval() {
+ String handleId = this.oAuthServiceHandleId;
+ if (handleId != null) {
+ oAuthFactory.deleteServiceAndAccessToken(handleId);
+ }
+ super.handleRemoval();
+ }
+
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(HomeConnectDiscoveryService.class);
eventSourceClient.getLatestEvents().clear();
eventSourceClient.dispose(immediate);
- oAuthFactory.ungetOAuthService(oAuthServiceHandleId);
+ String handleId = this.oAuthServiceHandleId;
+ if (handleId != null) {
+ oAuthFactory.ungetOAuthService(handleId);
+ }
homeConnectServlet.removeBridgeHandler(this);
}