orika-mapper / orika

Simpler, better and faster Java bean mapping framework
http://orika-mapper.github.io/orika-docs/
Apache License 2.0
1.29k stars 269 forks source link

NullPointer when WeakReference cached type is GC'd #343

Closed fernandosiq-dh closed 4 years ago

fernandosiq-dh commented 4 years ago

Hello,

We are currently having intermittent problems during unit tests in our build that breaks because of a NPE in Orika.

Here is my fix: https://github.com/orika-mapper/orika/pull/342/files

I investigated the issue, seems to be related to TypeFactory cache, that holds a WeakReference for the type that is not properly checked for nulls, and hence will return Null as Type.

Unfortunately there is no easy way to reproduce a WeakReference being GC'd, so I wasn't able to think of a unit test to share reproducing the problem.

stapetro commented 4 years ago

Please try to reproduce it with a test.

stapetro commented 4 years ago

@fernandosiq-dh Please close the issue since the pull request is now merged. Thx.