Resolve itest runbundles for Gson and Commons Lang upgrades and fix JsonParser deprecations (#10345)

* Resolve itest runbundles for Gson and Commons Lang upgrades
* Fix JsonParser deprecations too
* Fix feature verification

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-03-18 12:15:15 +01:00
committed by GitHub
parent 009208adee
commit 580f293766
86 changed files with 206 additions and 215 deletions

View File

@@ -36,7 +36,6 @@ import com.google.gson.JsonParser;
public class TradfriCoapHandler implements CoapHandler {
private final Logger logger = LoggerFactory.getLogger(TradfriCoapHandler.class);
private final JsonParser parser = new JsonParser();
private @Nullable CoapCallback callback;
private @Nullable CompletableFuture<String> future;
@@ -70,7 +69,7 @@ public class TradfriCoapHandler implements CoapHandler {
final CoapCallback callback = this.callback;
if (callback != null) {
try {
callback.onUpdate(parser.parse(response.getResponseText()));
callback.onUpdate(JsonParser.parseString(response.getResponseText()));
callback.setStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
} catch (JsonParseException e) {
logger.warn("Observed value is no valid json: {}, {}", response.getResponseText(), e.getMessage());

View File

@@ -17,7 +17,11 @@ import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -211,7 +215,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
if (gatewayResponse.isSuccess()) {
responseText = gatewayResponse.getResponseText();
json = new JsonParser().parse(responseText).getAsJsonObject();
json = JsonParser.parseString(responseText).getAsJsonObject();
preSharedKey = json.get(NEW_PSK_BY_GW).getAsString();
if (isNullOrEmpty(preSharedKey)) {
@@ -323,7 +327,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
deviceClient.setURI(gatewayInfoURI);
deviceClient.asyncGet().thenAccept(data -> {
logger.debug("requestGatewayInfo response: {}", data);
JsonObject json = new JsonParser().parse(data).getAsJsonObject();
JsonObject json = JsonParser.parseString(data).getAsJsonObject();
String firmwareVersion = json.get(VERSION).getAsString();
getThing().setProperty(Thing.PROPERTY_FIRMWARE_VERSION, firmwareVersion);
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
@@ -337,7 +341,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
deviceClient.setURI(gatewayURI + "/" + instanceId);
deviceClient.asyncGet().thenAccept(data -> {
logger.debug("requestDeviceDetails response: {}", data);
JsonObject json = new JsonParser().parse(data).getAsJsonObject();
JsonObject json = JsonParser.parseString(data).getAsJsonObject();
deviceUpdateListeners.forEach(listener -> listener.onUpdate(instanceId, json));
});
// restore root URI