Skip to content

Finalizer hit db on lazy dbrefs [DATAMONGO-1076] #1996

@spring-projects-issues

Description

@spring-projects-issues

Pablo Díaz-López opened DATAMONGO-1076 and commented

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


Affects: 1.6 GA (Evans)

Referenced from: pull request #234

Backported to: 1.6.1 (Evans SR1)

Metadata

Metadata

Labels

in: coreIssues in core supporttype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions