Findbugs all over #2

Mostly char encoding
Use StringWriter rather than OSW->BAOS->String
This commit is contained in:
zzz
2015-07-12 16:06:49 +00:00
parent 914cc120ad
commit 1f9bb046f5
25 changed files with 76 additions and 68 deletions

View File

@ -572,7 +572,7 @@ public class Reseeder {
System.err.println("Reseed got no router infos from " + seedURL);
return 0;
}
String content = new String(contentRaw);
String content = DataHelper.getUTF8(contentRaw);
// This isn't really URLs, but Base64 hashes
// but they may include % encoding
Set<String> urls = new HashSet<String>(1024);

View File

@ -442,7 +442,13 @@ class NtpMessage {
// or stratum-1 (primary) servers, this is a four-character ASCII
// string, left justified and zero padded to 32 bits.
if(stratum==0 || stratum==1) {
return new String(ref);
StringBuilder buf = new StringBuilder(4);
for (int i = 0; i < 4; i++) {
if (ref[i] == 0)
break;
buf.append((char) (ref[i] & 0xff));
}
return buf.toString();
}
// In NTP Version 3 secondary servers, this is the 32-bit IPv4