fix: Map key comparison, preventing NPE
This commit is contained in:
parent
1667579c15
commit
03fad8ff96
2 changed files with 4 additions and 2 deletions
|
@ -30,7 +30,7 @@ public class TemperaturesServiceImpl implements TemperaturesService {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return averages.get().get(city);
|
return averages.get().getOrDefault(city.toLowerCase(), List.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener(FileProcessedEvent.class)
|
@EventListener(FileProcessedEvent.class)
|
||||||
|
|
|
@ -79,7 +79,9 @@ public class FileLoadingService {
|
||||||
.map(line -> {
|
.map(line -> {
|
||||||
try {
|
try {
|
||||||
var parts = line.split(";");
|
var parts = line.split(";");
|
||||||
return new DataRow(parts[0], Integer.parseInt(parts[1].split("-")[0]), Double.parseDouble(parts[2]));
|
return new DataRow(parts[0].toLowerCase(),
|
||||||
|
Integer.parseInt(parts[1].split("-")[0]),
|
||||||
|
Double.parseDouble(parts[2]));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new FileProcessingException("Error in line %s".formatted(line), e);
|
throw new FileProcessingException("Error in line %s".formatted(line), e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue