This is an automated email from the ASF dual-hosted git repository.

damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ffd83a4cb7 UnoApp.close() was issuing XDesktop.terminate(), and then 
starting a timer that would kill OpenOffice 2 second seconds, while also 
killing it in the finally block, and not waiting for it to exit. This sometimes 
caused tests to start OpenOffice before the previous instance fully finished, 
especially in the fvt.uno.sc.formula.TestFormulaDocs test which starts up 
OpenOffice for each document, and then the new instance wouldn't start, causing 
test failures.
ffd83a4cb7 is described below

commit ffd83a4cb704a94fbafd9acb46745118915900f2
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Sat Jan 14 08:36:47 2023 +0200

    UnoApp.close() was issuing XDesktop.terminate(), and then starting a timer
    that would kill OpenOffice 2 second seconds, while also killing it in the
    finally block, and not waiting for it to exit. This sometimes caused tests
    to start OpenOffice before the previous instance fully finished,
    especially in the fvt.uno.sc.formula.TestFormulaDocs test which starts up
    OpenOffice for each document, and then the new instance wouldn't start,
    causing test failures.
    
    Rather, after issuing XDesktop.terminate(), wait up to 5 seconds for
    OpenOffice to exit. Only if it's still running, kill it. This is similar
    to what VclApp already does.
    
    Patch by: me
---
 .../source/org/openoffice/test/uno/UnoApp.java     | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/test/testuno/source/org/openoffice/test/uno/UnoApp.java 
b/test/testuno/source/org/openoffice/test/uno/UnoApp.java
index 261f3f5505..e089b2e691 100644
--- a/test/testuno/source/org/openoffice/test/uno/UnoApp.java
+++ b/test/testuno/source/org/openoffice/test/uno/UnoApp.java
@@ -23,7 +23,6 @@ package org.openoffice.test.uno;
 
 import java.io.File;
 import java.util.Timer;
-import java.util.TimerTask;
 
 import org.openoffice.test.OpenOffice;
 import org.openoffice.test.common.FileUtil;
@@ -119,29 +118,26 @@ public class UnoApp {
 
        private Timer timer = new Timer(true);
 
-       private TimerTask timerTask = null;
-
        /**
         * Shut down the connection and close OpenOffice
         */
        public void close() {
                try {
-                       timerTask = new TimerTask() {
-                               public void run() {
-                                       if (openOffice != null)
-                                               openOffice.kill();
-                               }
-                       };
-                       timer.schedule(timerTask, 1000 * 2);
                        desktop.terminate();
+                       if (openOffice != null) {
+                               // Wait 5 seconds for exit, checking every 500 
ms:
+                               for (int i = 0; i < 10; i++) {
+                                       if (!openOffice.isRunning())
+                                               break;
+                                       Thread.sleep(500);
+                               }
+                       }
                } catch (Exception e) {
                        // e.printStackTrace(); // for debugging
                } finally {
-                       if (openOffice != null)
+                       if (openOffice != null && openOffice.isRunning())
                                openOffice.kill();
 
-                       timerTask.cancel();
-                       timerTask = null;
                        componentContext = null;
                        componentFactory = null;
                        serviceFactory = null;

Reply via email to