Skip to content

client: Guard SimpleCache construction and document cache key behaviour#6561

Draft
VelikovPetar wants to merge 1 commit into
v6from
fix/video-cache-simplecache-guard-v6
Draft

client: Guard SimpleCache construction and document cache key behaviour#6561
VelikovPetar wants to merge 1 commit into
v6from
fix/video-cache-simplecache-guard-v6

Conversation

@VelikovPetar

Copy link
Copy Markdown
Contributor

Goal

Backport of the review fixes from #6542 to v6.

Guard against a crash during ChatClient initialisation when the SimpleCache
directory lock is stale (e.g. left by a prior process crash), and clarify
cache key semantics in the public docs.

Implementation

  • VideoMediaCache.create() now returns VideoMediaCache? and wraps
    SimpleCache construction in a try-catch. A stale directory lock no
    longer aborts ChatClient initialisation — video caching is silently
    disabled instead. ChatClient.kt already uses ?.let {} so the nullable
    return is handled transparently.
  • VideoCacheConfig KDoc: added a note that cache entries are keyed by URL
    path only (query parameters are stripped).
  • LRU eviction test: comment extended to acknowledge the wall-clock
    dependency of Thread.sleep spacing and what to do if the test flakes.

UI Changes

No UI changes.

Testing

./gradlew :stream-chat-android-client:testDebugUnitTest --tests "*.cache.*"

- VideoMediaCache.create() now returns VideoMediaCache? and wraps
  SimpleCache construction in a try-catch; a stale directory lock from a
  prior crash no longer aborts ChatClient initialisation — video caching
  is silently disabled instead.
- VideoCacheConfig KDoc notes that cache entries are keyed by URL path
  only (query parameters are stripped).
- LRU eviction test comment acknowledges the wall-clock dependency of
  the Thread.sleep spacing and what to do if the test becomes flaky.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@VelikovPetar VelikovPetar added the pr:improvement Improvement label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled (or ignored for dependabot PRs).

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.32 MB 0.05 MB 🟢
stream-chat-android-offline 5.49 MB 5.54 MB 0.04 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.75 MB 0.11 MB 🟢
stream-chat-android-compose 12.87 MB 12.96 MB 0.09 MB 🟢

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
66.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant