[infrastructure] move infered nullness warnings to error and update EEA (#8949)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K
2020-11-12 21:07:11 +01:00
committed by GitHub
parent 0856a0b3f2
commit ba4c96d99d
155 changed files with 644 additions and 632 deletions

View File

@@ -359,7 +359,11 @@ public class HueBridge {
List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
SuccessResponse response = entries.get(0);
return (String) response.success.get("/lights/" + enc(light.getId()) + "/name");
String lightName = (String) response.success.get("/lights/" + enc(light.getId()) + "/name");
if (lightName == null) {
throw new ApiException("Response didn't contain light name.");
}
return lightName;
}
/**
@@ -560,7 +564,11 @@ public class HueBridge {
List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
SuccessResponse response = entries.get(0);
return (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
String groupName = (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
if (groupName == null) {
throw new ApiException("Response didn't contain group name.");
}
return groupName;
}
/**
@@ -610,7 +618,11 @@ public class HueBridge {
List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
SuccessResponse response = entries.get(0);
return (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
String groupName = (String) response.success.get("/groups/" + enc(group.getId()) + "/name");
if (groupName == null) {
throw new ApiException("Response didn't contain group name.");
}
return groupName;
}
/**
@@ -955,7 +967,11 @@ public class HueBridge {
List<SuccessResponse> entries = safeFromJson(result.getBody(), SuccessResponse.GSON_TYPE);
SuccessResponse response = entries.get(0);
return (String) response.success.get("username");
String username = (String) response.success.get("username");
if (username == null) {
throw new ApiException("Response didn't contain username");
}
return username;
}
/**
@@ -1019,7 +1035,8 @@ public class HueBridge {
handleErrors(result);
return gson.fromJson(result.getBody(), FullConfig.class);
FullConfig fullConfig = gson.fromJson(result.getBody(), FullConfig.class);
return Objects.requireNonNull(fullConfig);
}
// Used as assert in requests that require authentication

View File

@@ -16,12 +16,7 @@ import static org.openhab.binding.hue.internal.HueBindingConstants.*;
import static org.openhab.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -162,8 +157,10 @@ public class HueBridgeNupnpDiscovery extends AbstractDiscoveryService {
try {
Gson gson = new Gson();
String json = doGetRequest(DISCOVERY_URL);
return gson.fromJson(json, new TypeToken<List<BridgeJsonParameters>>() {
}.getType());
List<BridgeJsonParameters> bridgeParameters = gson.fromJson(json,
new TypeToken<List<BridgeJsonParameters>>() {
}.getType());
return Objects.requireNonNull(bridgeParameters);
} catch (IOException e) {
logger.debug("Philips Hue NUPnP service not reachable. Can't discover bridges");
} catch (JsonParseException je) {