You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/05/25 11:56:11 UTC
[incubator-plc4x] branch master updated (c2a4ac4 -> 0b77062)
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git.
from c2a4ac4 Fixed some SonarQube findings
new e10549c Fixed some SonarQube findings
new 0b77062 Fixed some SonarQube findings
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../iotfactory/IotElasticsearchFactory.java | 31 ++++++++++++++++------
.../apache/plc4x/camel/Plc4XPollingConsumer.java | 9 ++++---
2 files changed, 28 insertions(+), 12 deletions(-)
--
To stop receiving notification emails like this one, please contact
cdutz@apache.org.
[incubator-plc4x] 02/02: Fixed some SonarQube findings
Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit 0b770620d4e02c5950229dbfbd08ebda79db72cc
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri May 25 13:56:03 2018 +0200
Fixed some SonarQube findings
---
.../iotfactory/IotElasticsearchFactory.java | 31 ++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/examples/iot-factory/src/main/java/org/apache/plc4x/java/examples/iotfactory/IotElasticsearchFactory.java b/examples/iot-factory/src/main/java/org/apache/plc4x/java/examples/iotfactory/IotElasticsearchFactory.java
index 8f70545..a89ea50 100644
--- a/examples/iot-factory/src/main/java/org/apache/plc4x/java/examples/iotfactory/IotElasticsearchFactory.java
+++ b/examples/iot-factory/src/main/java/org/apache/plc4x/java/examples/iotfactory/IotElasticsearchFactory.java
@@ -54,6 +54,15 @@ public class IotElasticsearchFactory {
RUNNING_RIGHT
}
+ private static class IotElasticsearchFactoryException extends RuntimeException {
+ private IotElasticsearchFactoryException(String message) {
+ super(message);
+ }
+ private IotElasticsearchFactoryException(String message, Throwable cause) {
+ super(message, cause);
+ }
+ }
+
private static class MyNode extends Node {
private MyNode(Settings preparedSettings, Collection<Class<? extends Plugin>> classpathPlugins) {
super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), classpathPlugins);
@@ -91,7 +100,7 @@ public class IotElasticsearchFactory {
" }", XContentType.JSON);
CreateIndexResponse createIndexResponse = indicesAdminClient.create(createIndexRequest).actionGet();
if(!createIndexResponse.isAcknowledged()) {
- throw new RuntimeException("Could not create index 'iot-factory-data'");
+ throw new IotElasticsearchFactoryException("Could not create index 'iot-factory-data'");
}
}
@@ -113,7 +122,7 @@ public class IotElasticsearchFactory {
" }", XContentType.JSON);
CreateIndexResponse createIndexResponse = indicesAdminClient.create(createIndexRequest).actionGet();
if(!createIndexResponse.isAcknowledged()) {
- throw new RuntimeException("Could not create index 'iot-product-data'");
+ throw new IotElasticsearchFactoryException("Could not create index 'iot-product-data'");
}
}
}
@@ -167,7 +176,7 @@ public class IotElasticsearchFactory {
boolean conveyorRight = (input & 64) != 0;
try {
- return XContentFactory.jsonBuilder()
+ XContentBuilder builder = XContentFactory.jsonBuilder()
.startObject()
.field("time", Calendar.getInstance().getTimeInMillis())
.field("conveyorEntry", conveyorEntry)
@@ -178,8 +187,10 @@ public class IotElasticsearchFactory {
.field( "conveyorLeft", conveyorLeft)
.field( "conveyorRight", conveyorRight)
.endObject();
+ builder.close();
+ return builder;
} catch (IOException e) {
- throw new RuntimeException("Error building JSON message.", e);
+ throw new IotElasticsearchFactoryException("Error building JSON message.", e);
}
}
@@ -191,24 +202,28 @@ public class IotElasticsearchFactory {
if (transferLeft) {
conveyorState = ConveyorState.RUNNING_LEFT;
try {
- return XContentFactory.jsonBuilder()
+ XContentBuilder builder = XContentFactory.jsonBuilder()
.startObject()
.field("time", Calendar.getInstance().getTimeInMillis())
.field("type", "small")
.endObject();
+ builder.close();
+ return builder;
} catch (IOException e) {
- throw new RuntimeException("Error building JSON message.", e);
+ throw new IotElasticsearchFactoryException("Error building JSON message.", e);
}
} else if (transferRight){
conveyorState = ConveyorState.RUNNING_RIGHT;
try {
- return XContentFactory.jsonBuilder()
+ XContentBuilder builder = XContentFactory.jsonBuilder()
.startObject()
.field("time", Calendar.getInstance().getTimeInMillis())
.field("type", "large")
.endObject();
+ builder.close();
+ return builder;
} catch (IOException e) {
- throw new RuntimeException("Error building JSON message.", e);
+ throw new IotElasticsearchFactoryException("Error building JSON message.", e);
}
}
} else if (!(transferLeft || transferRight)) {
--
To stop receiving notification emails like this one, please contact
cdutz@apache.org.
[incubator-plc4x] 01/02: Fixed some SonarQube findings
Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit e10549c80c629b87c46078644587f50640f32625
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri May 25 13:47:29 2018 +0200
Fixed some SonarQube findings
---
.../main/java/org/apache/plc4x/camel/Plc4XPollingConsumer.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XPollingConsumer.java b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XPollingConsumer.java
index d338143..e9c5406 100644
--- a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XPollingConsumer.java
+++ b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XPollingConsumer.java
@@ -113,7 +113,7 @@ public class Plc4XPollingConsumer extends ServiceSupport implements PollingConsu
@Override
protected void doStart() {
-
+ // We don't seem to need to do anything special here.
}
@Override
@@ -125,13 +125,14 @@ public class Plc4XPollingConsumer extends ServiceSupport implements PollingConsu
}
}
- public Object unwrapIfSingle(List list) {
- if (list.size() < 1) {
+ private Object unwrapIfSingle(List list) {
+ if (list.isEmpty()) {
return null;
}
- if (list.size() < 2) {
+ if (list.size() == 1) {
return list.get(0);
}
return list;
}
+
}
--
To stop receiving notification emails like this one, please contact
cdutz@apache.org.