Skip to content

Conversation

@ratacolita
Copy link

The bug was in line 22 of TypeHandlerBase.cs:
if (x != null && y != null) return false;

This condition returns false when BOTH objects are non-null, which is the normal comparison case. This caused the ConcurrentDictionary to:

  1. Never find existing cache entries (Equals always returns false)
  2. Add a new entry for every SetValue() call
  3. Grow unboundedly causing memory leaks in production

The fix changes the null checks to proper equality semantics:
if (x == null && y == null) return true; // Both null = equal
if (x == null || y == null) return false; // One null = not equal

Added unit test to verify cache reuse behavior.

🤖 Generated with Claude Code

The bug was in line 22 of TypeHandlerBase.cs:
  if (x != null && y != null) return false;

This condition returns false when BOTH objects are non-null, which is
the normal comparison case. This caused the ConcurrentDictionary to:
1. Never find existing cache entries (Equals always returns false)
2. Add a new entry for every SetValue() call
3. Grow unboundedly causing memory leaks in production

The fix changes the null checks to proper equality semantics:
  if (x == null && y == null) return true;   // Both null = equal
  if (x == null || y == null) return false;  // One null = not equal

Added unit test to verify cache reuse behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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