[JAVA-3775] Concurrency issue causing PropertyModel.getCachedCodec to return null Created: 02/Jul/20 Updated: 28/Oct/23 Resolved: 08/Oct/20 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | POJO |
| Affects Version/s: | 3.12.5 |
| Fix Version/s: | 4.2.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jeroen Sikkes | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
java 8, mongodb 4.2.8 |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
I'm getting a NullPointerException in EncoderContext.encodeWithChildContext when encoding POJO's with many nested objects using multiple threads. After a random number of serializations PropertyModel.getCachedCodec keeps returning null and the method fails when it is called by PojoCodecImpl.encodeValue
The issue could be related to / the same asĀ |
| Comments |
| Comment by Githook User [ 08/Oct/20 ] | ||||||||||||||||
|
Author: {'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}Message: Fix PojoCodec caching (#585) Reduce the number of required CodecRegistry lookups for properties
| ||||||||||||||||
| Comment by Ross Lawley [ 10/Jul/20 ] | ||||||||||||||||
| Comment by Jeroen Sikkes [ 07/Jul/20 ] | ||||||||||||||||
|
Hi Ross, I have spent a short time fiddeling with the java-driver and don't have time to continue at this moment. Additional investigation will be needed. The following question arise to me investigating the stacktrace: What happens if another thread is accessing the classModel entry in the codecCache before the for loop addToCache is completed? In the PojoCodecImpl the following method exists:
Re-ordering the implementation to:
prevents the NPE to occur. | ||||||||||||||||
| Comment by Ross Lawley [ 03/Jul/20 ] | ||||||||||||||||
|
Thanks jsikkes@xs4all.nl for the ticket and the example code. |