SDK will deadlock for no apparent reason too!
Please see the corresponding code. After listShapes gets the result, all threads should be terminated. However, the line in the picture is still not destroyed. Continuous triggering will cause the server to freeze.
https://imgur.com/a/Ll4F8Q5
<dependencies>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-core</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-identity</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-bom</artifactId>
<version>3.42.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
public List<String> listShapes(String region, String domain) {
OciUtils ociUtils = new OciUtils(Region.valueOf(region), oracleConfig.getComptentId());
return ociUtils.listShapes(domain);
}
import com.oracle.bmc.ConfigFileReader;
import com.oracle.bmc.Region;
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.core.ComputeClient;
import com.oracle.bmc.core.ComputeWaiters;
import com.oracle.bmc.core.VirtualNetworkClient;
import com.oracle.bmc.core.model.*;
import com.oracle.bmc.core.requests.*;
import com.oracle.bmc.core.responses.*;
import com.oracle.bmc.identity.IdentityClient;
import com.oracle.bmc.identity.model.AvailabilityDomain;
import com.oracle.bmc.identity.requests.ListAvailabilityDomainsRequest;
import com.oracle.bmc.identity.responses.ListAvailabilityDomainsResponse;
import com.oracle.bmc.workrequests.WorkRequestClient;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class OciUtils {
private ComputeClient computeClient;
private WorkRequestClient workRequestClient;
private ComputeWaiters computeWaiters;
private IdentityClient identityClient;
private VirtualNetworkClient virtualNetworkClient;
private String sshPubKeyFilePath;
private String compartentId;
private Region region;
private static final Logger OCI_MANAGER_LOGGER = LoggerFactory.getLogger("ociManagerAppender");
public OciUtils(Region region, String compartentId) {
this.compartentId = compartentId;
final ConfigFileReader.ConfigFile configFile;
try {
configFile = ConfigFileReader.parseDefault();
} catch (IOException e) {
throw new RuntimeException(e);
}
final AuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider(configFile);
this.computeClient = ComputeClient.builder().region(region).build(provider);
this.workRequestClient = WorkRequestClient.builder().build(provider);
workRequestClient.setRegion(region);
this.computeWaiters = computeClient.newWaiters(workRequestClient);
this.identityClient = IdentityClient.builder().build(provider);
identityClient.setRegion(region);
this.virtualNetworkClient = VirtualNetworkClient.builder().build(provider);
virtualNetworkClient.setRegion(region);
}
...
public List<String> listShapes(String domainName) {
List<String> shapesList = new ArrayList<>();
ListShapesRequest listShapesRequest = ListShapesRequest.builder().availabilityDomaindomainName).compartmentId(compartentId).build();
ListShapesResponse listShapesResponse = computeClient.listShapes(listShapesRequest);
List<Shape> shapes = listShapesResponse.getItems();
if (shapes.isEmpty()) {
throw new IllegalStateException("No available shape was found.");
}
for(Shape shape : shapes) {
shapesList.add(shape.getShape());
}
return shapesList;
}
}
I have tried : https://github.com/oracle/oci-java-sdk/issues/596 ,but this thread just haved.
ComputeClient.builder().clientConfigurator(builder -> {
builder.property(JerseyClientProperties.USE_APACHE_CONNECTOR, false);
}).region(region).build(provider);
ComputeClient.builder()..clientConfigurator(builder -> {
builder.property(JerseyClientProperties.APACHE_IDLE_CONNECTION_MONITOR_THREAD_ENABLED, false);
})...
computeClient.listShapes(listShapesRequest);--->
package com.oracle.bmc.http.internal;
....
public <R> R listenForResult(CompletionStage<R> stage) throws Throwable {
Waiter<R> waiter = new Waiter();
waiter.listenForResult(stage);
return waiter.waitAndWork();
}
this code creates jersey-client-async-executor-xxx , but does not kill it after returning the result.Please fix this bug or Tell me how to avoid
Hi , @balckduck , I wanted to check if you're still experiencing the issue with the jersey-client-async-executor threads not being destroyed after calling listShapes. If so, have you found any workarounds, or would you like me to follow up with the SDK team on this?
listShapes @richachugh11 Hi,I haven't found a solution, I hope the SDK team needs to follow up it