HADOOP-10203. Connection leak in Jets3tNativeFileSystemStore#retrieveMetadata. Contributed by Andrei Savu.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1561720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aaron Myers 2014-01-27 16:18:04 +00:00
parent 9875656581
commit 5e2d2dd56b
2 changed files with 14 additions and 5 deletions

View File

@ -536,6 +536,9 @@ Release 2.4.0 - UNRELEASED
HADOOP-10252. HttpServer can't start if hostname is not specified. (Jimmy HADOOP-10252. HttpServer can't start if hostname is not specified. (Jimmy
Xiang via atm) Xiang via atm)
HADOOP-10203. Connection leak in
Jets3tNativeFileSystemStore#retrieveMetadata. (Andrei Savu via atm)
Release 2.3.0 - UNRELEASED Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -110,23 +110,29 @@ public void storeEmptyFile(String key) throws IOException {
handleS3ServiceException(e); handleS3ServiceException(e);
} }
} }
@Override @Override
public FileMetadata retrieveMetadata(String key) throws IOException { public FileMetadata retrieveMetadata(String key) throws IOException {
StorageObject object = null;
try { try {
if(LOG.isDebugEnabled()) { if(LOG.isDebugEnabled()) {
LOG.debug("Getting metadata for key: " + key + " from bucket:" + bucket.getName()); LOG.debug("Getting metadata for key: " + key + " from bucket:" + bucket.getName());
} }
S3Object object = s3Service.getObject(bucket.getName(), key); object = s3Service.getObjectDetails(bucket.getName(), key);
return new FileMetadata(key, object.getContentLength(), return new FileMetadata(key, object.getContentLength(),
object.getLastModifiedDate().getTime()); object.getLastModifiedDate().getTime());
} catch (S3ServiceException e) {
} catch (ServiceException e) {
// Following is brittle. Is there a better way? // Following is brittle. Is there a better way?
if (e.getS3ErrorCode().matches("NoSuchKey")) { if ("NoSuchKey".equals(e.getErrorCode())) {
return null; //return null if key not found return null; //return null if key not found
} }
handleS3ServiceException(e); handleServiceException(e);
return null; //never returned - keep compiler happy return null; //never returned - keep compiler happy
} finally {
if (object != null) {
object.closeDataInputStream();
}
} }
} }