fix checkstyle (#21102)

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
This commit is contained in:
Bernd Weymann
2026-07-09 23:05:42 +02:00
committed by GitHub
parent 8b20e4b839
commit 9cbd1456eb
5 changed files with 15 additions and 9 deletions
@@ -487,7 +487,7 @@ public class Authorization {
private String generateCodeVerifier(int size) { private String generateCodeVerifier(int size) {
String verifierBytes = StringUtils.getRandomAlphanumeric(size); String verifierBytes = StringUtils.getRandomAlphanumeric(size);
return Base64.getUrlEncoder().withoutPadding().encodeToString(verifierBytes.getBytes()); return Base64.getUrlEncoder().withoutPadding().encodeToString(verifierBytes.getBytes(StandardCharsets.UTF_8));
} }
public void addBasicHeaders(Request req) { public void addBasicHeaders(Request req) {
@@ -15,6 +15,7 @@ package org.openhab.binding.mercedesme.internal.api;
import static org.openhab.binding.mercedesme.internal.Constants.*; import static org.openhab.binding.mercedesme.internal.Constants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -149,7 +150,7 @@ public class RestApi extends Authorization {
for (int i = 0; i < words.length; i++) { for (int i = 0; i < words.length; i++) {
String word = words[i]; String word = words[i];
word = word.isEmpty() ? word word = word.isEmpty() ? word
: Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase(); : Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase(Locale.ROOT);
builder.append(word); builder.append(word);
} }
String value = ((JSONObject) object).get("isAvailable").toString(); String value = ((JSONObject) object).get("isAvailable").toString();
@@ -16,6 +16,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -320,7 +321,7 @@ public class Websocket extends RestApi {
try { try {
String pingId = UUID.randomUUID().toString(); String pingId = UUID.randomUUID().toString();
pingPongMap.put(pingId, Instant.now()); pingPongMap.put(pingId, Instant.now());
localSession.getRemote().sendPing(ByteBuffer.wrap(pingId.getBytes())); localSession.getRemote().sendPing(ByteBuffer.wrap(pingId.getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) { } catch (IOException e) {
logger.warn("Websocket ping failed {}", e.getMessage()); logger.warn("Websocket ping failed {}", e.getMessage());
} }
@@ -333,7 +334,7 @@ public class Websocket extends RestApi {
for (int i = 0; i < frame.getPayloadLength(); i++) { for (int i = 0; i < frame.getPayloadLength(); i++) {
bytes[i] = buffer.get(i); bytes[i] = buffer.get(i);
} }
String payloadString = new String(bytes); String payloadString = new String(bytes, StandardCharsets.UTF_8);
Instant sent = pingPongMap.remove(payloadString); Instant sent = pingPongMap.remove(payloadString);
if (sent == null) { if (sent == null) {
logger.debug("Websocket received pong without ping {}", payloadString); logger.debug("Websocket received pong without ping {}", payloadString);
@@ -12,6 +12,7 @@
*/ */
package org.openhab.binding.mercedesme.internal.discovery; package org.openhab.binding.mercedesme.internal.discovery;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -61,7 +62,7 @@ public class MercedesMeDiscoveryService extends AbstractDiscoveryService {
properties.put("vin", vin); properties.put("vin", vin);
thingDiscovered(DiscoveryResultBuilder.create(new ThingUID(ttuid, ac.getThing().getUID(), vin)) thingDiscovered(DiscoveryResultBuilder.create(new ThingUID(ttuid, ac.getThing().getUID(), vin))
.withBridge(ac.getThing().getUID()).withProperties(properties).withRepresentationProperty("vin") .withBridge(ac.getThing().getUID()).withProperties(properties).withRepresentationProperty("vin")
.withLabel("Mercedes Benz " + ttuid.getId().toUpperCase()).build()); .withLabel("Mercedes Benz " + ttuid.getId().toUpperCase(Locale.ROOT)).build());
} }
} }
@@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
@@ -55,11 +54,15 @@ public class ThingCallbackListener implements ThingHandlerCallback {
public Map<String, State> updatesReceived = new HashMap<>(); public Map<String, State> updatesReceived = new HashMap<>();
public Map<String, Map<String, State>> updatesPerGroupMap = new HashMap<>(); public Map<String, Map<String, State>> updatesPerGroupMap = new HashMap<>();
public boolean linked = false; public boolean linked = false;
public Optional<ThingStatusInfo> status = Optional.empty(); private @Nullable ThingStatusInfo status;
private Instant waitTime = Instant.MAX; private Instant waitTime = Instant.MAX;
public ThingStatusInfo getThingStatus() { public ThingStatusInfo getThingStatus() {
return status.get(); ThingStatusInfo localStatus = status;
if (localStatus == null) {
throw new IllegalStateException("No status update received yet");
}
return localStatus;
} }
public int getUpdatesForGroup(String group) { public int getUpdatesForGroup(String group) {
@@ -108,7 +111,7 @@ public class ThingCallbackListener implements ThingHandlerCallback {
@Override @Override
public void statusUpdated(Thing thing, ThingStatusInfo thingStatus) { public void statusUpdated(Thing thing, ThingStatusInfo thingStatus) {
status = Optional.of(thingStatus); status = thingStatus;
} }
@Override @Override