Skip to content

Thread blocking cause by the default setting #388

Open
@JokerForCode

Description

@JokerForCode

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions