Skip to content

cache: guard null fields in Entry.writeTo() to fix NPE (#8962)#9345

Open
iVamsi wants to merge 1 commit intosquare:masterfrom
iVamsi:fix/cache-entry-write-npe-8962
Open

cache: guard null fields in Entry.writeTo() to fix NPE (#8962)#9345
iVamsi wants to merge 1 commit intosquare:masterfrom
iVamsi:fix/cache-entry-write-npe-8962

Conversation

@iVamsi
Copy link

@iVamsi iVamsi commented Feb 28, 2026

Fix NullPointerException in Cache.Entry.writeTo() when an HTTPS response has a null handshake.

Fix

Changed if (url.isHttps) to if (url.isHttps && handshake != null) so the TLS block is skipped when handshake is absent. The response still succeeds. It just won't be served from cache on subsequent requests.

Tests added

Three regression tests in CacheTest:

  • HTTPS response with null handshake does not crash writeTo().
  • Multiple HTTPS requests with null handshake all succeed
  • HTTPS response with null handshake is not served from cache

All verified to fail before the fix and pass after.

Fixes #8962

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.

NullPointerException in Cache.Entry.writeTo()

1 participant