Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1076

Finalizer hit db on lazy dbrefs

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6 GA (Evans)
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Windows 7 64bits running on a Oracle JDK 8u20

      Description

      If we load a Document class that has a lazy annotated DBRef, and we do not navigate through it, the data is not requested to MongoDB as expected, but if we force a GC it seems that the proxy that envelops the attribute with DBRef generates a request to MongoDB.

      You can see this issue in logs if trace logs are enabled:

      Example to a DBRef to MY_DB.PEOPLE with id=18

      2014-10-27 12:24:02.644  INFO 4384 --- [      Finalizer] com.mongodb.TRACE                        : find: MY_DB.PEOPLE { "_id" : 18}
      

      And this is the trace I get debugging:

      	at com.testapp.model.People$$EnhancerByCGLIB$$c7ff2ba0.finalize(<generated>)
      	at java.lang.System$2.invokeFinalize(System.java:1267)
      	at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:98)
      	at java.lang.ref.Finalizer.access$100(Finalizer.java:34)
      	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:210)
      

      The problem seems to be at DefaultDbRefResolver creating the LazyLoadingInterceptor inner class.

        Attachments

          Activity

            People

            Assignee:
            thomasd Thomas Darimont
            Reporter:
            padilo Pablo Díaz-López
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: