diff --git a/api/src/main/java/io/minio/MinioClient.java b/api/src/main/java/io/minio/MinioClient.java index 73ac0287e..542f11b48 100755 --- a/api/src/main/java/io/minio/MinioClient.java +++ b/api/src/main/java/io/minio/MinioClient.java @@ -1547,8 +1547,24 @@ public ObjectStat statObject(String bucketName, String objectName, ServerSideEnc headers = sse.headers(); } + checkBucketName(bucketName); + String errorMessage = ""; + if ( objectName == null ) { + errorMessage += " Object name cannot be null."; + } else if ( objectName.equals("") ) { + errorMessage += " Object name cannot be empty."; + } + if ( !errorMessage.equals("") ) { + throw new InvalidArgumentException("Invalid Stat Object Argument(s)." + errorMessage); + } HttpResponse response = executeHead(bucketName, objectName, headers); ResponseHeader header = response.header(); + if ( header.contentLength() == 0 + && header.contentType() == null + && header.statusCode() == null ) { + throw new InvalidArgumentException("Invalid Stat Object Arguments."); + } + Map> httpHeaders = response.httpHeaders(); ObjectStat objectStat = new ObjectStat(bucketName, objectName, header, httpHeaders); return objectStat;