in app/story_packages/services/S3.scala [20:47]
private def withS3Result[T](key: String)(action: S3Object => T): Option[T] = config.aws.s3Client.flatMap { client =>
try {
val request = new GetObjectRequest(bucket, key)
val result = client.getObject(request)
// http://stackoverflow.com/questions/17782937/connectionpooltimeoutexception-when-iterating-objects-in-s3
try {
Some(action(result))
}
catch {
case e: Exception =>
S3ClientExceptionsMetric.increment()
throw e
}
finally {
result.close()
}
} catch {
case e: AmazonS3Exception if e.getStatusCode == 404 => {
Logger.warn("not found at %s - %s" format(bucket, key))
None
}
case e: Exception => {
S3ClientExceptionsMetric.increment()
throw e
}
}
}