Skip to content

Commit 87c8a22

Browse files
committed
more copilot stuff
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
1 parent e061a6b commit 87c8a22

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/connection/Clip2Bridge.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ private static String doHTTP(String url, String method, @Nullable String request
590590
}
591591

592592
LOGGER.trace("{} {} HTTP/1.1 {TCP} {}", method, url, request == null ? "" : ">> " + request);
593+
if (status > 299) {
594+
LOGGER.debug("HTTP/1.1 {} {}", status, connection.getResponseMessage());
595+
throw new IOException("HTTP error " + status);
596+
}
593597
try (InputStream in = connection.getInputStream()) {
594598
String response = new String(in.readAllBytes(), StandardCharsets.UTF_8);
595599
LOGGER.trace("HTTP/1.1 {} {} << {}", status, connection.getResponseMessage(), response);
@@ -643,6 +647,10 @@ private static String doHTTPS(String url, String method, @Nullable String reques
643647
int status = connection.getResponseCode();
644648

645649
LOGGER.trace("{} {} HTTP/1.1 {TLS} {}", method, url, request == null ? "" : ">> " + request);
650+
if (status > 299) {
651+
LOGGER.debug("HTTP/1.1 {} {}", status, connection.getResponseMessage());
652+
throw new IOException("HTTP error " + status);
653+
}
646654
try (InputStream in = connection.getInputStream()) {
647655
String response = new String(in.readAllBytes(), StandardCharsets.UTF_8);
648656
LOGGER.trace("HTTP/1.1 {} {} << {}", status, connection.getResponseMessage(), response);
@@ -743,11 +751,10 @@ public static boolean isClip2Supported(String hostName) throws IOException {
743751
private static final Pattern IPV4_PATTERN = Pattern.compile(IPV4_REGEX);
744752

745753
/**
746-
* Static reference to the most recently created instance of this class, which allows the static
747-
* doHTTPS() method to use the instance SSL context if available, otherwise fallback to the static
748-
* TRUST_ALL_CONTEXT. This is necessary because the doHTTP() method is used for the initial
749-
* registration call before the instance is created and the SSL context is configured, but we
750-
* want to use the instance SSL context for all subsequent calls.
754+
* In case the class has been instantiated we use the instance SSL context for the static doHTTP() method,
755+
* otherwise we fall back to a static trust all SSL context. This allows the static doHTTP() method to be
756+
* used for the initial registration call before the instance is created and the SSL context is configured,
757+
* and to use the instance SSL context for all subsequent calls.
751758
*/
752759
private static final SSLContext TRUST_ALL_CONTEXT = createTrustAllSslContext();
753760
private final SSLContext hueContext;
@@ -1461,7 +1468,7 @@ public void testConnectionState() throws HttpUnauthorizedException, ApiException
14611468
return config.getUpdateStatusMap();
14621469
}
14631470
} catch (IOException e) {
1464-
LOGGER.debug("getUpdateStatus() error '{}'", e.getMessage());
1471+
LOGGER.debug("getUpdateStatusMap() error '{}'", e.getMessage());
14651472
}
14661473
return new HashMap<>();
14671474
}

bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2BridgeHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,6 @@ private void pollSoftwareStatus() {
921921
/**
922922
* Add or remove the given device software update status entry to/from the map of all device software
923923
* update statuses.
924-
*
925-
* @return the maximum update status of the bridge and all devices.
926924
*/
927925
private void putSoftwareStatus(String id, @Nullable UpdateStatusV2 status) {
928926
if (status == null || status == UpdateStatusV2.NO_UPDATE) {

0 commit comments

Comments
 (0)