diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-06-04 09:49:54 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-04 10:04:21 +0200 |
commit | 3766f2a0d3bc50919366b0e43f5ee8c814019c8b (patch) | |
tree | ddd24e51bc76bb1f8d7817d0fd2a29e3677c98cf /connectivity | |
parent | 1d7220d0346c336ca6d7fd6b79beccd1daa070cd (diff) |
Finalizers must not access UNO objects
If the object being finalized (A) has the last reference to the UNO object (B),
and B is actually a proxy for a remote UNO object, then A and B become eligible
for finalization in parallel, and the finalizer of B may already have run when
the finalizer for A runs. That means that B may already have been removed from
the remote bridge, causing an "unknown OID" error from the remote end when the
finalizer of A now tries to make a call on B.
(We try to assert that close() has actually been called before finalize() calls
delete(), but the corresponding exception may be silently swallowed by the JVM
finalization machinery.)
This caused spurious "URP: queryInterface request message with unknown OID
received" failures during JunitTest_dbaccess_unoapi.
Change-Id: Ia47c3ef2c22a6adc75b1b8271eb4b3140accebe7
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/Jar_ConnectivityTools.mk | 4 | ||||
-rw-r--r-- | connectivity/qa/connectivity/tools/AbstractDatabase.java | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/connectivity/Jar_ConnectivityTools.mk b/connectivity/Jar_ConnectivityTools.mk index e398d7372ef0..fc8a861f2b8a 100644 --- a/connectivity/Jar_ConnectivityTools.mk +++ b/connectivity/Jar_ConnectivityTools.mk @@ -19,6 +19,10 @@ $(eval $(call gb_Jar_use_jars,ConnectivityTools,\ OOoRunner \ )) +$(eval $(call gb_Jar_use_system_jars,ConnectivityTools, \ + $(OOO_JUNIT_JAR) \ +)) + $(eval $(call gb_Jar_set_packageroot,ConnectivityTools,connectivity)) $(eval $(call gb_Jar_add_sourcefiles,ConnectivityTools,\ diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java index 3207dafcd6e8..f7295d948517 100644 --- a/connectivity/qa/connectivity/tools/AbstractDatabase.java +++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java @@ -31,6 +31,7 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.util.CloseVetoException; import connectivity.tools.sdb.Connection; import java.io.File; +import static org.junit.Assert.*; public abstract class AbstractDatabase implements DatabaseAccess { @@ -120,7 +121,11 @@ public abstract class AbstractDatabase implements DatabaseAccess public void closeAndDelete() { close(); + delete(); + } + private void delete() + { if (m_databaseDocumentFile != null) { final File file = new File(m_databaseDocumentFile); @@ -184,7 +189,16 @@ public abstract class AbstractDatabase implements DatabaseAccess @Override protected void finalize() throws Throwable { - closeAndDelete(); + // Cannot call close() here, as it accesses UNO objects (that may + // already have been finalized): + assertNull( + "missing call to connectivity.tools.AbstractDatabase.close", + m_connection); + assertNull( + "missing call to connectivity.tools.AbstractDatabase.close", + m_databaseDocument); + + delete(); super.finalize(); } |