Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1364

BasicPersistentEntity.getPersistentProperty(…) returns the unchecked value in ConcurrentReferenceHashMap

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Complete
    • Affects Version/s: 2.1 RC1 (Lovelace), 2.0.9 (Kay SR9)
    • Component/s: Core
    • Labels:
      None

      Description

      ConcurrentReferenceHashMap was introduced by this commit . However getPersistentProperty still uses propertyCache.get(name).

      https://github.com/spring-projects/spring-data-commons/blob/2.1.0.RC1/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java#L309

      Javadoc says

      NOTE: The use of references means that there is no guarantee that items placed into the map will be subsequently available. The garbage collector may discard references at any time, so it may appear that an unknown thread is silently removing entries. 

      I had some issues  related to this after several hours after deploying an application.
      here is an example.

      Using computeIfAbsent or ConcurrentHashMap will solve this issue.
       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mp911de Mark Paluch
                Reporter:
                making Toshiaki Maki
                Last updater:
                Mark Paluch
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: