Skip to content

Thread blocking cause by the default setting #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JokerForCode opened this issue Nov 5, 2021 · 2 comments
Open

Thread blocking cause by the default setting #388

JokerForCode opened this issue Nov 5, 2021 · 2 comments

Comments

@JokerForCode
Copy link

JokerForCode commented Nov 5, 2021

Only set up the variable "requestTimeoutEnabled" and "requestTimeout" both of “ClientBuilderConfiguration”,the ossClient will be block until time-out,and throw timeoutException.However, the “requestTimeoutEnabled” is set up "false", or the "requestTimeout" is set up 'null',the request of OSS Http will occur timeout,but in the code,it never throw exception,the thread will be block until dead.

the right code to catch exception:

ClientBuilderConfiguration configuration = new ClientBuilderConfiguration();
configuration.setRequestTimeoutEnabled(Boolean.TRUE);
configuration.setRequestTimeout(300_000);
OSS aliyunOssClient = new OSSClientBuilder().build(xxx,xxx,xxx,configuration);
try{
   String fileUrl = aliyunOssClient.getObject(bucketName,filePath).getResponse().getUri();
}catch (Throwable cause){
    // here will be catch
    cause.printStackTrace();
}

the wrong code to catch exception:

OSS aliyunOssClient = new OSSClientBuilder().build(xxx,xxx,xxx);
try{
   String fileUrl = aliyunOssClient.getObject(bucketName,filePath).getResponse().getUri();
}catch (Throwable cause){
    // here will not be catch,the thread will be block until dead
    cause.printStackTrace();
}
@JokerForCode
Copy link
Author

That is the solution

public class ClientConfiguration {
    ...omit  some code...
    public static final int DEFAULT_CONNECTION_REQUEST_TIMEOUT = 5 * 60 * 1000;
    public static final int DEFAULT_CONNECTION_TIMEOUT = 50 * 1000;
}

JokerForCode added a commit to JokerForCode/aliyun-oss-java-sdk that referenced this issue Nov 12, 2021
Fix thread blocking cause by the default setting
@JokerForCode
Copy link
Author

Hello,Anybody here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant