Skip to content

Commit

Permalink
[JENKINS-33593] Fixing animal-sniffer detected errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfergom authored and dbmeneses committed Apr 18, 2016
1 parent e9785a5 commit 950b23f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/java/hudson/plugins/sonar/client/HttpClient.java
Expand Up @@ -21,6 +21,8 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;

import com.google.common.base.Charsets;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
Expand All @@ -37,12 +39,12 @@ public String getHttp(String urlToRead, String username, String password) throws
if (!StringUtils.isEmpty(password)) {
userpass = userpass + password;
}
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes(StandardCharsets.UTF_8));
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes(Charsets.UTF_8));
conn.setRequestProperty("Authorization", basicAuth);
}

conn.setRequestMethod("GET");
InputStream is = conn.getInputStream();
return IOUtils.toString(is, StandardCharsets.UTF_8.name());
return IOUtils.toString(is, Charsets.UTF_8.name());
}
}
Expand Up @@ -36,6 +36,8 @@
import hudson.console.LineTransformationOutputStream;
import org.apache.commons.lang.StringUtils;

import com.google.common.base.Charsets;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -88,11 +90,11 @@ public MaskPasswordsOutputStream(OutputStream logger, Collection<String> passwor

@Override
protected void eol(byte[] bytes, int len) throws IOException {
String line = new String(bytes, 0, len, StandardCharsets.UTF_8);
String line = new String(bytes, 0, len, Charsets.UTF_8);
if (passwordsAsPattern != null && !line.contains(URL_IN_LOGS)) {
line = passwordsAsPattern.matcher(line).replaceAll(REPLACEMENT);
}
logger.write(line.getBytes(StandardCharsets.UTF_8));
logger.write(line.getBytes(Charsets.UTF_8));
}

@Override
Expand Down

0 comments on commit 950b23f

Please sign in to comment.