-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust to JDK 11 concurrency implementation; make thread leackage tes…
…t effective; fix it. 1. Executors do not allocate threads before tasks are submitted. This made the thread leak test ineffective as no thread was allocated to begin with. 2. Runnables obtained from Executor.shutdownNow() cannot be run without another executor because they override Runnable.run() to NOT run when the parent executor was shut down. Refactor initialization to not rely on executing executor tasks in the calling thread. 3. Added an asynchronous client creation interface DisconnectedDittoClient to ensure that resources are released if client creation failed. Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
- Loading branch information
Showing
12 changed files
with
385 additions
and
250 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
java/src/main/java/org/eclipse/ditto/client/DisconnectedDittoClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.client; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
|
||
/** | ||
* Client interface before connecting. | ||
*/ | ||
public interface DisconnectedDittoClient { | ||
|
||
/** | ||
* Connect the client to the configured Ditto back-end. | ||
* If this method is called more than once, the result is not defined. | ||
* | ||
* @return a future that completes with the connected client. | ||
*/ | ||
CompletionStage<DittoClient> connect(); | ||
|
||
/** | ||
* Release resources held by this client. | ||
*/ | ||
void destroy(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.