Skip to content

fix: add null safety to FileDiff getBefore/getAfter#28

Open
yangyu0227 wants to merge 1 commit into
LaiZhou:mainfrom
yangyu0227:fix/npe-null-safety
Open

fix: add null safety to FileDiff getBefore/getAfter#28
yangyu0227 wants to merge 1 commit into
LaiZhou:mainfrom
yangyu0227:fix/npe-null-safety

Conversation

@yangyu0227
Copy link
Copy Markdown

Root cause: SseEventListener's Gson instance does not register FileDiffDeserializer, so when the server sends SSE diff events with null 'before'/'after' values, Gson creates FileDiff instances with null fields (bypassing constructor via UnsafeAllocator).

Fix:

  1. Register FileDiffDeserializer in SseEventListener's Gson builder (prevents null fields at the source)
  2. Add null-safe elvis operator in SessionManager.resolveBeforeContent (defense in depth)

Root cause: SseEventListener's Gson instance does not register
FileDiffDeserializer, so when the server sends SSE diff events
with null 'before'/'after' values, Gson creates FileDiff instances
with null fields (bypassing constructor via UnsafeAllocator).

Fix:
1. Register FileDiffDeserializer in SseEventListener's Gson builder
   (prevents null fields at the source)
2. Add null-safe elvis operator in SessionManager.resolveBeforeContent
   (defense in depth)
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.

1 participant