aliyun / aliyun-oss-java-sdk

Aliyun OSS SDK for Java
1.22k stars 805 forks source link

doesObjectExist never returns when object exists #168

Open arafato opened 5 years ago

arafato commented 5 years ago

Hi--,

the call ossClient.doesObjectExist from the Java SDK waits until all bytes according to content length header have been transmitted, which will never happen, since the underlying API getObjectMeta (https://www.alibabacloud.com/help/doc-detail/31985.htm) does not return a body. This is happening in the INTL portal in eu-central-1

Example Code (Please make sure that the object exists and has a size >= 1):

final OSSClient ossClient = new OSSClient("http://oss-eu-central-1.aliyuncs.com", accessKeyId, accessKeySecret);
// Following call never returns
final boolean found = ossClient.doesObjectExist("mybucket", "IDoExist.dat");
ossClient.shutdown();
Shallwewu commented 5 years ago

Hi--,

the call ossClient.doesObjectExist from the Java SDK waits until all bytes according to content length header have been transmitted, which will never happen, since the underlying API getObjectMeta (https://www.alibabacloud.com/help/doc-detail/31985.htm) does not return a body. This is happening in the INTL portal in eu-central-1

Example Code (Please make sure that the object exists and has a size >= 1):

final OSSClient ossClient = new OSSClient("http://oss-eu-central-1.aliyuncs.com", accessKeyId, accessKeySecret);
// Following call never returns
final boolean found = ossClient.doesObjectExist("mybucket", "IDoExist.dat");
ossClient.shutdown();

doesObjectExist uses getSimplifiedObjectMeta API internally, which is a HTTP GET method; getObjectMeta actually is a HTTP HEAD method. These call getSimplifiedObjectMeta and getObjectMeta both return object meta info without returning the object body.

liudanking commented 3 years ago

Hi--, the call ossClient.doesObjectExist from the Java SDK waits until all bytes according to content length header have been transmitted, which will never happen, since the underlying API getObjectMeta (https://www.alibabacloud.com/help/doc-detail/31985.htm) does not return a body. This is happening in the INTL portal in eu-central-1 Example Code (Please make sure that the object exists and has a size >= 1):

final OSSClient ossClient = new OSSClient("http://oss-eu-central-1.aliyuncs.com", accessKeyId, accessKeySecret);
// Following call never returns
final boolean found = ossClient.doesObjectExist("mybucket", "IDoExist.dat");
ossClient.shutdown();

doesObjectExist uses getSimplifiedObjectMeta API internally, which is a HTTP GET method; getObjectMeta actually is a HTTP HEAD method. These call getSimplifiedObjectMeta and getObjectMeta both return object meta info without returning the object body.

quite clear comment, and this issues seems fixed in 3.11:

image