[fmiweather] Fix UNDEF observations in corner case situations. (#11025)
* [fmiweather] Fix UNDEF observations in corner case situations. In addition, tests added for static utility functions in AbstractWeatherHandler. Resolves #11024. Signed-off-by: Sami Salonen <ssalonen@gmail.com>
This commit is contained in:
@@ -165,18 +165,13 @@ public abstract class AbstractWeatherHandler extends BaseThingHandler {
|
||||
if (data.values.length < 2) {
|
||||
throw new IllegalStateException("Excepted at least two data items");
|
||||
}
|
||||
if (data.values[0] == null) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 1; i < data.values.length; i++) {
|
||||
if (data.values[i] == null) {
|
||||
return i - 1;
|
||||
for (int i = data.values.length - 1; i >= 0; i--) {
|
||||
if (data.values[i] != null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (data.values[data.values.length - 1] == null) {
|
||||
return -1;
|
||||
}
|
||||
return data.values.length - 1;
|
||||
// if we have reached here, it means that array was full of nulls
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected static long floorToEvenMinutes(long epochSeconds, int roundMinutes) {
|
||||
|
||||
Reference in New Issue
Block a user