Skip to content

Share one HTTP client between all UrlTileProviders - #55

Merged
afarber merged 1 commit into
mainfrom
share-overlay-http-client
Oct 13, 2026
Merged

afarber merged 1 commit into
mainfrom
share-overlay-http-client

Conversation

@afarber

@afarber afarber commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Fixes #53

Each UrlTileProvider created its own Ktor HttpClient, and nothing in the library closed it. Since PredefinedTileProviders hands out a new provider on every call, toggling overlays (as in Example09) kept piling up clients with their own connection pools.

Now all providers share one lazily created client, which lives as long as the process. close() is still there so existing code compiles, but it's deprecated and does nothing. Otherwise one caller could close the client for all the others.

Two new tests check that providers share the client and that close() leaves it open.

Every UrlTileProvider built its own Ktor client and the library never
closed it. PredefinedTileProviders returns a new provider on each call,
so switching overlays on and off kept adding clients.

- All UrlTileProvider instances now use one lazily created client
- close() is deprecated and does nothing, so existing callers still
  compile but can't close the client for everybody else
- Tests check that providers share the client and that close() keeps
  it open
@afarber
afarber merged commit 01f3e5c into main Oct 13, 2026
14 checks passed
@afarber
afarber deleted the share-overlay-http-client branch October 13, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Every UrlTileProvider creates an HttpClient that is never closed

1 participant