FIXUP: Fix a possible NPE and cast 10_000 to double

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-08-19 11:36:16 -06:00
rodzic 667bae488b
commit e92bfd38bb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -234,19 +234,21 @@ public final class MapPaintUtils {
private static void writeData(OutputStream out, BufferedReader bufferedReader, String group, List<String> sources)
throws IOException {
String line = bufferedReader.readLine();
while (!line.contains("End Settings for the paint style")) {
while (line != null && !line.contains("End Settings for the paint style")) {
out.write(line.getBytes(StandardCharsets.UTF_8));
out.write(System.lineSeparator().getBytes(StandardCharsets.UTF_8));
line = bufferedReader.readLine();
}
/* Finish writing the comment */
while (!line.endsWith("*/")) {
while (line != null && !line.endsWith("*/")) {
out.write(line.getBytes(StandardCharsets.UTF_8));
out.write(System.lineSeparator().getBytes(StandardCharsets.UTF_8));
line = bufferedReader.readLine();
}
out.write(line.getBytes(StandardCharsets.UTF_8));
out.write(System.lineSeparator().getBytes(StandardCharsets.UTF_8));
if (line != null) {
out.write(line.getBytes(StandardCharsets.UTF_8));
out.write(System.lineSeparator().getBytes(StandardCharsets.UTF_8));
}
for (String source : sources) {
out.write(System.lineSeparator().getBytes(StandardCharsets.UTF_8));
@ -284,7 +286,7 @@ public final class MapPaintUtils {
crc.update(sourceName.getBytes(StandardCharsets.UTF_8));
double bucket = crc.getValue() / CRC_DIVIDE_TO_TEN_K_MAX;
double bucketSize = 10_000 / colors.length;
double bucketSize = 10_000d / colors.length;
for (int i = 1; i <= colors.length; i++) {
if (bucket < bucketSize * i) {
return colors[i - 1].getColor();