From 6ef1b9add57b194ccfb4d66feaf89ba71d40a7ab Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 2 Nov 2024 00:29:16 +1300 Subject: [PATCH] Add null check for Content-Type header --- .../openhab/binding/sony/internal/net/HttpRequest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.sony/src/main/java/org/openhab/binding/sony/internal/net/HttpRequest.java b/bundles/org.openhab.binding.sony/src/main/java/org/openhab/binding/sony/internal/net/HttpRequest.java index e78fc66a71e28..263bf3a5ca90c 100644 --- a/bundles/org.openhab.binding.sony/src/main/java/org/openhab/binding/sony/internal/net/HttpRequest.java +++ b/bundles/org.openhab.binding.sony/src/main/java/org/openhab/binding/sony/internal/net/HttpRequest.java @@ -100,12 +100,14 @@ public HttpResponse sendGetCommand(final String url, final Header... rqstHeaders // Sony may report ill-formed content response final MultivaluedMap metadata = response.getMetadata(); final List content = metadata.get("Content-Type"); - for (int index = 0; index < content.size(); index++) { - if (content.get(index) instanceof String entry) { - content.set(index, entry.replaceAll(".+:", "").trim()); + if (content != null) { + for (int index = 0; index < content.size(); index++) { + if (content.get(index) instanceof String entry) { + content.set(index, entry.replaceAll(".+:", "").trim()); + } } + metadata.put("Content-Type", content); } - metadata.put("Content-Type", content); return new HttpResponse(Response.fromResponse(response).replaceAll(metadata).build()); } } catch (ProcessingException | IllegalStateException | IOException e) {