From 9cec7107a9fa09b42ebc992567ce52efde77ea85 Mon Sep 17 00:00:00 2001 From: Jae Hyeon Bae Date: Fri, 18 Jul 2014 09:50:15 -0700 Subject: [PATCH] Properties.load instead of manual population --- .../storage/s3/FileSessionCredentialsProvider.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/s3-extensions/src/main/java/io/druid/storage/s3/FileSessionCredentialsProvider.java b/s3-extensions/src/main/java/io/druid/storage/s3/FileSessionCredentialsProvider.java index dbb1a288407..cf6efed0e3d 100644 --- a/s3-extensions/src/main/java/io/druid/storage/s3/FileSessionCredentialsProvider.java +++ b/s3-extensions/src/main/java/io/druid/storage/s3/FileSessionCredentialsProvider.java @@ -25,7 +25,10 @@ import com.amazonaws.auth.AWSSessionCredentials; import com.google.common.base.Charsets; import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; @@ -80,12 +83,10 @@ public class FileSessionCredentialsProvider implements AWSCredentialsProvider { @Override public void refresh() { try { - List lines = Files.readAllLines(Paths.get(sessionCredentials), Charsets.UTF_8); Properties props = new Properties(); - for (String line : lines) { - String[] tokens = line.split("="); - props.put(tokens[0], tokens[1]); - } + InputStream is = new FileInputStream(new File(sessionCredentials)); + props.load(is); + is.close(); sessionToken = props.getProperty("sessionToken"); accessKey = props.getProperty("accessKey");