Dapper.Oracle
Dapper.Oracle copied to clipboard
Fix memory leak in TypeHandlerBase.DictionaryKeyComparer.Equals
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:
- Never find existing cache entries (Equals always returns false)
- Add a new entry for every SetValue() call
- 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