From 2e812935619134cb54600145e5228e151ee6e47e Mon Sep 17 00:00:00 2001 From: Egor Blagov Date: Wed, 11 Sep 2019 10:56:34 +0700 Subject: [PATCH] Sync with v2.60+ - jeromq update - gradle update to 4.2.1 - fixed responses handling (single instead of list handling) - fixed request empty params --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- .../com/exalttech/trex/core/ConnectionManager.java | 2 ++ src/main/java/com/exalttech/trex/core/RPCCommands.java | 6 +++--- src/main/java/com/exalttech/trex/core/RPCMethods.java | 2 +- .../trex/remote/models/params/PingParams.java | 4 ++++ src/main/java/com/exalttech/trex/ui/PortsManager.java | 10 +++++++++- .../trex/ui/controllers/MainViewController.java | 2 +- 8 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/exalttech/trex/remote/models/params/PingParams.java diff --git a/build.gradle b/build.gradle index d2e3c0da..b4bddcd4 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ test { task uiTest(type: Test) { description 'Runs UI testing(E2E)' outputs.upToDateWhen { false } - testClassesDir = sourceSets.uiTest.output.classesDir + testClassesDirs = sourceSets.uiTest.output.classesDirs classpath = sourceSets.uiTest.runtimeClasspath testLogging { @@ -73,7 +73,7 @@ dependencies { compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.6.0' compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version:'2.5.4' compile group: 'org.json', name: 'json', version:'20150729' - compile group: 'org.zeromq', name: 'jeromq', version:'0.4.0' + compile group: 'org.zeromq', name: 'jeromq', version:'0.5.1' compile group: 'commons-io', name: 'commons-io', version:'2.4' compile group: 'commons-lang', name: 'commons-lang', version:'2.4' compile group: 'com.google.code.gson', name: 'gson', version:'2.7' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 88b4a670..1c245900 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Feb 01 15:27:25 NOVT 2019 +#Tue Sep 10 13:45:42 NOVT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip diff --git a/src/main/java/com/exalttech/trex/core/ConnectionManager.java b/src/main/java/com/exalttech/trex/core/ConnectionManager.java index ca7ea861..315b2248 100644 --- a/src/main/java/com/exalttech/trex/core/ConnectionManager.java +++ b/src/main/java/com/exalttech/trex/core/ConnectionManager.java @@ -247,6 +247,8 @@ public String sendRequest(String cmd, String parameters) { param = "{" + apiHParam + " , " + parameters + "}"; } + } else { + param = "{}"; } String request = "{ \"id\" : \"aggogxls\", \"jsonrpc\" : \"2.0\", \"method\" : \"" + cmd + "\", \"params\" :" + param + " }"; LOG.trace("Sending request \n" + Util.toPrettyFormat(request)); diff --git a/src/main/java/com/exalttech/trex/core/RPCCommands.java b/src/main/java/com/exalttech/trex/core/RPCCommands.java index 42475837..3eda9eec 100644 --- a/src/main/java/com/exalttech/trex/core/RPCCommands.java +++ b/src/main/java/com/exalttech/trex/core/RPCCommands.java @@ -54,15 +54,15 @@ private static String sendRequest(final String command, final Map portIndexes) { if (response == null) { return; } - List portStatusList = mapper.readValue(response, mapper.getTypeFactory().constructCollectionType(List.class, PortStatus.class)); + List portStatusList = new ArrayList<>(); + + try { + portStatusList = mapper.readValue(response, mapper.getTypeFactory().constructCollectionType(List.class, PortStatus.class)); + } catch (MismatchedInputException ex) { + portStatusList.add(mapper.readValue(response, mapper.getTypeFactory().constructType(PortStatus.class))); + } + for (Port port : list) { PortStatus.PortStatusResult portStatus = portStatusList.get(list.indexOf(port)).getResult(); port.setOwner(portStatus.getOwner()); diff --git a/src/main/java/com/exalttech/trex/ui/controllers/MainViewController.java b/src/main/java/com/exalttech/trex/ui/controllers/MainViewController.java index 4a5a4ffb..3ef1e30b 100644 --- a/src/main/java/com/exalttech/trex/ui/controllers/MainViewController.java +++ b/src/main/java/com/exalttech/trex/ui/controllers/MainViewController.java @@ -394,7 +394,7 @@ private void loadSystemInfo() { String versionResponse = ConnectionManager.getInstance().sendRequest("get_version", ""); Gson gson = new Gson(); - JsonObject version = gson.fromJson(versionResponse, JsonArray.class).get(0).getAsJsonObject(); + JsonObject version = gson.fromJson(versionResponse, JsonObject.class); systemInfoReq.getResult().setApiVersion(version.getAsJsonObject("result").getAsJsonPrimitive("version").getAsString()); LogsController.getInstance().appendText(LogType.INFO, "Loading port information complete"); }