Simplify instanceof checks (#19645)

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen
2025-11-27 22:17:03 +01:00
committed by GitHub
parent 9fd5fdd441
commit 51e0654c11
3 changed files with 5 additions and 10 deletions
@@ -156,8 +156,7 @@ public class IndegoController {
} catch (TimeoutException e) {
throw new IndegoException(e);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
if (e.getCause() instanceof HttpResponseException httpResponseException) {
Response response = httpResponseException.getResponse();
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
/*
@@ -216,8 +215,7 @@ public class IndegoController {
} catch (TimeoutException e) {
throw new IndegoException(e);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
if (e.getCause() instanceof HttpResponseException httpResponseException) {
Response response = httpResponseException.getResponse();
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
/*
@@ -315,8 +313,7 @@ public class IndegoController {
} catch (TimeoutException e) {
throw new IndegoException(e);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
if (e.getCause() instanceof HttpResponseException httpResponseException) {
Response response = httpResponseException.getResponse();
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
/*
@@ -95,8 +95,7 @@ public class Client {
return parseXmlResponse(responseContent, configResolution);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
if (e.getCause() instanceof HttpResponseException httpResponseException) {
Response response = httpResponseException.getResponse();
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
/*
@@ -377,8 +377,7 @@ public class SleepIQImpl implements SleepIQ {
throw new CommunicationException("Communication error while accessing API: " + e.getMessage());
} catch (ExecutionException e) {
logger.debug("SleepIQ: doRequest: ExecutionException message={}", e.getMessage(), e);
Throwable cause = e.getCause();
if (cause instanceof HttpResponseException httpResponseException) {
if (e.getCause() instanceof HttpResponseException httpResponseException) {
Response response = httpResponseException.getResponse();
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
/*