[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:
@@ -142,9 +142,10 @@ public class SmartherAuthorizationServlet extends HttpServlet {
|
||||
final StringBuffer requestURL = request.getRequestURL();
|
||||
|
||||
// Try to infer the real protocol from request headers
|
||||
final String realProtocol = StringUtil.defaultIfBlank(request.getHeader(X_FORWARDED_PROTO),
|
||||
request.getScheme());
|
||||
|
||||
String realProtocol = request.getHeader(X_FORWARDED_PROTO);
|
||||
if (realProtocol == null || realProtocol.isBlank()) {
|
||||
realProtocol = request.getScheme();
|
||||
}
|
||||
return requestURL.replace(0, requestURL.indexOf(":"), realProtocol).toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -177,7 +178,9 @@ public class SmartherApi {
|
||||
public ModuleStatus getModuleStatus(String plantId, String moduleId) throws SmartherGatewayException {
|
||||
try {
|
||||
final ContentResponse response = requestModule(GET, plantId, moduleId, null);
|
||||
return ModelUtil.gsonInstance().fromJson(response.getContentAsString(), ModuleStatus.class);
|
||||
ModuleStatus moduleStatus = ModelUtil.gsonInstance().fromJson(response.getContentAsString(),
|
||||
ModuleStatus.class);
|
||||
return Objects.requireNonNull(moduleStatus);
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new SmartherGatewayException(e.getMessage());
|
||||
}
|
||||
@@ -280,9 +283,13 @@ public class SmartherApi {
|
||||
if (response.getStatus() == HttpStatus.NO_CONTENT_204) {
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
return ModelUtil.gsonInstance().fromJson(response.getContentAsString(),
|
||||
List<Subscription> subscriptions = ModelUtil.gsonInstance().fromJson(response.getContentAsString(),
|
||||
new TypeToken<List<Subscription>>() {
|
||||
}.getType());
|
||||
if (subscriptions == null) {
|
||||
throw new SmartherGatewayException("fromJson returned null");
|
||||
}
|
||||
return subscriptions;
|
||||
}
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new SmartherGatewayException(e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user