summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-04-14 18:11:11 +0200
committerMichael Stahl <mstahl@redhat.com>2012-04-14 21:07:14 +0200
commit228515e7783aecdb992258765554a530d6c831f3 (patch)
tree1cb0394c17b067fae17347659fcfbe50e4f6763e /unotest
parent40aaefeb25190b2c63212f1b5cc353abfc7b0def (diff)
OfficeConnection: kill soffice process when Java bridge is disposed
In the rare case that the soffice process outlives the Java side UNO bridge, ensure that soffice.bin doesn't continue running.
Diffstat (limited to 'unotest')
-rw-r--r--unotest/source/java/org/openoffice/test/OfficeConnection.java39
1 files changed, 24 insertions, 15 deletions
diff --git a/unotest/source/java/org/openoffice/test/OfficeConnection.java b/unotest/source/java/org/openoffice/test/OfficeConnection.java
index 5eb3afa88723..2b7e34fd307a 100644
--- a/unotest/source/java/org/openoffice/test/OfficeConnection.java
+++ b/unotest/source/java/org/openoffice/test/OfficeConnection.java
@@ -119,24 +119,33 @@ public final class OfficeConnection {
boolean desktopTerminated = true;
if (process != null) {
if (context != null) {
- XMultiComponentFactory factory = context.getServiceManager();
- assertNotNull(factory);
- XDesktop desktop = UnoRuntime.queryInterface(
- XDesktop.class,
- factory.createInstanceWithContext(
- "com.sun.star.frame.Desktop", context));
- context = null;
+ XDesktop desktop = null;
try {
- desktopTerminated = desktop.terminate();
- if (!desktopTerminated) {
- // in case terminate() fails we would wait forever
- // for the process to die, so kill it
- process.destroy();
- }
- assertTrue(desktopTerminated);
- } catch (DisposedException e) {}
+ XMultiComponentFactory factory =
+ context.getServiceManager();
+ assertNotNull(factory);
+ desktop = UnoRuntime.queryInterface(XDesktop.class,
+ factory.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", context));
+ } catch (DisposedException e) {
+ // it can happen that the Java bridge was disposed
+ // already, we want to ensure soffice.bin is killed
+ process.destroy();
+ }
+ context = null;
+ if (desktop != null) {
+ try {
+ desktopTerminated = desktop.terminate();
+ if (!desktopTerminated) {
+ // in case terminate() fails we would wait
+ // forever for the process to die, so kill it
+ process.destroy();
+ }
+ assertTrue(desktopTerminated);
+ } catch (DisposedException e) {}
// it appears that DisposedExceptions can already happen
// while receiving the response of the terminate call
+ }
desktop = null;
} else {
process.destroy();