[Couchbase lite 2.8] [java] why System.exit in getting started?

Hello,

In the getting started example the code finished by a System.exit because “This is needed for a tidy closedown of work executors” and if I don’t put this instruction, the java process is still executing in background.

I tried by stopping replication with a replicator.stop() but it doesn’t change anything.
Is it a bug in java couchbase lite api ?

When cblite logs are activated, I can see this log at the very end:

V/CouchbaseLite/NETWORK:AbstractCBLWebSocket{ws://<sync_gateway_url>//_blipsync}:OkHTTP closing:
V/CouchbaseLite/DATABASE:StateMachine@0x3e519de4: no transition: CLOSING => CLOSE_REQUESTED [CLOSED]
java.lang.Exception
at com.couchbase.lite.internal.utils.StateMachine.setState(StateMachine.java:150)
at com.couchbase.lite.internal.replicator.AbstractCBLWebSocket$CBLWebSocketListener.onClosing(AbstractCBLWebSocket.java:193)
at okhttp3.internal.ws.RealWebSocket.onReadClose(RealWebSocket.java:361)
at okhttp3.internal.ws.WebSocketReader.readControlFrame(WebSocketReader.java:202)
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:103)
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:273)
at okhttp3.internal.ws.RealWebSocket$1.onResponse(RealWebSocket.java:209)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

Hi @dmihura,
Is there a problem? Is there behavior that you expected and that did not happen. That logged exception is just a warning, nothing to worry about.

Hi, I don’t expect anything on this exception (thrown at the very end of each replication when continous mode is set with false value …), it’s just surprising, and I’ve wondered if it was the reason why the java process is not being terminated properly (without this explicit system.exit()) at the very end of the exemple provided by couchbase about the console app.

If you run this example, the jvm process will never exit without this explicit system.exit(). It could be a resource leak (for example du to a non proper termination of a single thread with one treatment ) and that’s why I would like to know if there is a correct way to shut down a one-shot replication (continous mode == false). I tried to put a replicator.stop() instead of the system.exit() but it doesn’t change anything, the jvm process is still runnning at the end of the program (and do nothing else than wait the end of an executor …).
Does it could mean, in a desktop application, that we could have as many executors not shutdown properly as we perform replications? (we want to implement a replicaton “on demand”)