Title: HomekitRoot leaks connections in it's subscriptionManager when calling "start" then "stop" · Issue #54 · hap-java/HAP-Java · GitHub
Open Graph Title: HomekitRoot leaks connections in it's subscriptionManager when calling "start" then "stop" · Issue #54 · hap-java/HAP-Java
X Title: HomekitRoot leaks connections in it's subscriptionManager when calling "start" then "stop" · Issue #54 · hap-java/HAP-Java
Description: I've come to notice this issue when working on the Homekit extension for Openhab2. When I reload the bundle, it calls homekitRoot.stop(), followed by a reload of the Java classes, followed by a homekitRoot.start(). What I'm noticing is t...
Open Graph Description: I've come to notice this issue when working on the Homekit extension for Openhab2. When I reload the bundle, it calls homekitRoot.stop(), followed by a reload of the Java classes, followed by a hom...
X Description: I've come to notice this issue when working on the Homekit extension for Openhab2. When I reload the bundle, it calls homekitRoot.stop(), followed by a reload of the Java classes, followed by a...
Opengraph URL: https://github.com/hap-java/HAP-Java/issues/54
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"HomekitRoot leaks connections in it's subscriptionManager when calling \"start\" then \"stop\"","articleBody":"I've come to notice this issue when working on the Homekit extension for Openhab2. When I reload the bundle, it calls `homekitRoot.stop()`, followed by a reload of the Java classes, followed by a `homekitRoot.start()`. What I'm noticing is that the subscriptions from before are accumulating, resulting in more and more [`SubscriptionManager::publish`](https://github.com/beowulfe/HAP-Java/blob/3ec72649c59671d2d917fa9072bdd6aef55bccaa/src/main/java/com/beowulfe/hap/impl/connections/SubscriptionManager.java#L84) calls with each reload.\r\n\r\nHere's what I'll see in the logs when toggling a homekit switch from the iOS client during the first load:\r\n\r\n```\r\n11:22:58.773 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n```\r\n\r\nThen, after, say, 5 reloads of the bundle (resulting in a call to `HomekitRoot::stop()` and `HomekitRoot::start() each time`, toggling a switch from the iOS client will cause that message to be logged an additional five times:\r\n\r\n```\r\n12:03:21.146 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n12:03:21.146 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n12:03:21.146 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n12:03:21.146 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n12:03:21.146 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n12:03:21.146 [INFO ] [.impl.connections.SubscriptionManager] - Publishing changes for 612672328\r\n```\r\n\r\nAfter digging around, it looks like [characteristic.unsubscribe() in SubscriptionManage.java#L71](https://github.com/beowulfe/HAP-Java/blob/3ec72649c59671d2d917fa9072bdd6aef55bccaa/src/main/java/com/beowulfe/hap/impl/connections/SubscriptionManager.java#L71) isn't getting called during `stop()`. I added some log messages to log when a connection is removed via [SubscriptionManager::removeConnection()](https://github.com/beowulfe/HAP-Java/blob/3ec72649c59671d2d917fa9072bdd6aef55bccaa/src/main/java/com/beowulfe/hap/impl/connections/SubscriptionManager.java#L64) and [SubscriptionManager::removeSubscription(...)](https://github.com/beowulfe/HAP-Java/blob/3ec72649c59671d2d917fa9072bdd6aef55bccaa/src/main/java/com/beowulfe/hap/impl/connections/SubscriptionManager.java#L48), and neither are invoked nor do connections appear to be ever removed. I'm not sure what mechanism is expected to clean these up, but the failure to have these cleaned up is what's leading to the accumulation of characteristic subscriptions.","author":{"url":"https://github.com/timcharper","@type":"Person","name":"timcharper"},"datePublished":"2019-01-21T20:56:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/54/HAP-Java/issues/54"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d25a0b77-7a43-6f28-d197-d1d63a652ca8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C5B2:79909:102461B:14C886C:69746DEA |
| html-safe-nonce | 43ac5db1f1e316dc6a3224ab1e314b34d61c02398ec122c31b64b77f1d39fd76 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUIyOjc5OTA5OjEwMjQ2MUI6MTRDODg2Qzo2OTc0NkRFQSIsInZpc2l0b3JfaWQiOiI1NDg5OTA3MzI2NDI2MzEyMTcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 54b1befebe1765c69199ce62cdd474d4e236d159446dfe56738cc32f75a3b470 |
| hovercard-subject-tag | issue:401507681 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hap-java/HAP-Java/54/issue_layout |
| twitter:image | https://opengraph.githubassets.com/60ef95e000f457f88225714114674846e4f6874ec71f1205cc1d80c58300ab7a/hap-java/HAP-Java/issues/54 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/60ef95e000f457f88225714114674846e4f6874ec71f1205cc1d80c58300ab7a/hap-java/HAP-Java/issues/54 |
| og:image:alt | I've come to notice this issue when working on the Homekit extension for Openhab2. When I reload the bundle, it calls homekitRoot.stop(), followed by a reload of the Java classes, followed by a hom... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timcharper |
| hostname | github.com |
| expected-hostname | github.com |
| None | e0b95d743b7672c9ac0e1032d5f117950182dc164a83434a7db86510e8f0b37c |
| turbo-cache-control | no-preview |
| go-import | github.com/hap-java/HAP-Java git https://github.com/hap-java/HAP-Java.git |
| octolytics-dimension-user_id | 47992845 |
| octolytics-dimension-user_login | hap-java |
| octolytics-dimension-repository_id | 31193475 |
| octolytics-dimension-repository_nwo | hap-java/HAP-Java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31193475 |
| octolytics-dimension-repository_network_root_nwo | hap-java/HAP-Java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fe7e2e8de6e57740bca50402351ea656f7a4bf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width