Bug 127625 - Java application wait for MessageDispatcher thread when using remote bridge
Summary: Java application wait for MessageDispatcher thread when using remote bridge
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
6.2.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-18 15:04 UTC by Oleg Shchelykalnov
Modified: 2019-09-26 10:08 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Test class (1.60 KB, text/plain)
2019-09-18 15:04 UTC, Oleg Shchelykalnov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Shchelykalnov 2019-09-18 15:04:48 UTC
Created attachment 154264 [details]
Test class

When I trying to write a simple Java application to connect to remote headless LibreOffice server.

I use SDK from maven. I found some documentation https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Java/Getting_a_Service_Manager and got com.sun.star.frame.XDesktop object, but next application doesn't stop.

In the debugger I got MessageDispatcher who waits for messages from the server:

SocketInputStream.socketRead0	
SocketInputStream.socketRead:116	
SocketInputStream.read:171	
SocketInputStream.read:141	
BufferedInputStream.fill:246	
BufferedInputStream.read1:286	
BufferedInputStream.read:345	
Hidden Source Calls	
SocketConnection.read:138	
XConnectionInputStream_Adapter.read:48	
DataInputStream.readInt:387	
Hidden Source Calls	
urp.readBlock:364	
urp.readMessage:96	
java_remote_bridge$MessageDispatcher.run:92	

I've tried to call XDesktop::terminate() method in the end but as expected it closed remote LibreOffice.

Are there other way to disconnect from the server and stop application?
Comment 1 Oleg Shchelykalnov 2019-09-19 07:04:17 UTC
Found documentation here https://wiki.openoffice.org/wiki/Uno/Remote/Tutorials/Disposing_Remote_Bridges
and example here: https://www.programcreek.com/java-api-examples/?code=LibreOffice/noa-libre/noa-libre-master/src/ag/ion/bion/officelayer/internal/application/connection/RemoteOfficeConnection.java

This snippet allows application to be correctly closed:

			Object oBridgeFactory = xcomponentcontext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.BridgeFactory", xcomponentcontext);
			XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class, oBridgeFactory);
			for (XBridge bridge : xBridgeFactory.getExistingBridges()) {
				XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, bridge);
				xComponent.dispose();
			}
Comment 2 Xisco Faulí 2019-09-26 10:08:24 UTC
Closing as RESOLVED NOTABUG