aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-07-16 10:05:34 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-07-16 10:05:34 +0200
commitc6d22a745bfe5e9b34331ed57a1c64e1d04fce8a (patch)
tree488b070651d112a2b3b8a0d62a46d796a73961b9 /sonar-server/src/main
parent9bf3be187a4893ad424eb09e3cd3c8e7c54f06d6 (diff)
downloadsonarqube-c6d22a745bfe5e9b34331ed57a1c64e1d04fce8a.tar.gz
sonarqube-c6d22a745bfe5e9b34331ed57a1c64e1d04fce8a.zip
Remove UriReader#openStream()
Let's keep API simple.
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
index e7407901e76..7e99d0c044e 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
@@ -19,6 +19,7 @@
*/
package org.sonar.server.plugins;
+import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.slf4j.LoggerFactory;
import org.sonar.api.Properties;
@@ -30,7 +31,8 @@ import org.sonar.api.utils.UriReader;
import org.sonar.updatecenter.common.UpdateCenter;
import org.sonar.updatecenter.common.UpdateCenterDeserializer;
-import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
@@ -95,21 +97,21 @@ public class UpdateCenterClient implements ServerComponent {
}
private UpdateCenter init() {
- InputStream input = null;
+ Reader reader = null;
try {
- input = uriReader.openStream(uri);
- if (input != null) {
- java.util.Properties properties = new java.util.Properties();
- properties.load(input);
- return UpdateCenterDeserializer.fromProperties(properties);
- }
+ String content = uriReader.readString(uri, Charsets.UTF_8);
+ java.util.Properties properties = new java.util.Properties();
+ reader = new StringReader(content);
+ properties.load(reader);
+ return UpdateCenterDeserializer.fromProperties(properties);
+
} catch (Exception e) {
LoggerFactory.getLogger(getClass()).error("Fail to connect to update center", e);
+ return null;
} finally {
- IOUtils.closeQuietly(input);
+ IOUtils.closeQuietly(reader);
}
- return null;
}
}