summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-16 02:03:12 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-16 02:04:11 +0100
commit952d4f5aab9913f961e77fa0457da5d38f31d94f (patch)
treed482ebae10ff11b3096dd85d927eca75825574d6 /plugins
parenta65e4772f4557a109917532b2d9c49680ce3bb15 (diff)
Fix Sonar issues in apex
Fixing various Sonar issues in apex. Issue-ID: POLICY-1034 Change-Id: Ie693637d75bd7e38c71b7ba04886fb75636276ed Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java6
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java2
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java2
-rw-r--r--plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java2
7 files changed, 11 insertions, 11 deletions
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
index a9418d834..ed2b521c4 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
@@ -210,7 +210,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
private String getJsonString(final Object object, final Object conditionedObject) {
- try (final ByteArrayOutputStream output = new ByteArrayOutputStream();) {
+ try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
final DatumWriter<Object> writer = new GenericDatumWriter<>(avroSchema);
final JsonEncoder jsonEncoder = EncoderFactory.get().jsonEncoder(avroSchema, output, true);
writer.write(conditionedObject, jsonEncoder);
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
index de324512b..303165558 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
@@ -101,7 +101,7 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn
// Check if we actually got a connection factory
if (connectionFactory == null) {
- throw new NullPointerException(
+ throw new IllegalArgumentException(
"JMS context lookup of \"" + jmsConsumerProperties.getConnectionFactory() + "\" returned null");
}
} catch (final Exception e) {
@@ -118,7 +118,7 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn
// Check if we actually got a topic
if (jmsIncomingTopic == null) {
- throw new NullPointerException(
+ throw new IllegalArgumentException(
"JMS context lookup of \"" + jmsConsumerProperties.getConsumerTopic() + "\" returned null");
}
} catch (final Exception e) {
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
index 0580d7159..83321e432 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
@@ -103,7 +103,7 @@ public class ApexJmsProducer implements ApexEventProducer {
// Check if we actually got a connection factory
if (connectionFactory == null) {
- throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
+ throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
+ "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
@@ -121,7 +121,7 @@ public class ApexJmsProducer implements ApexEventProducer {
// Check if we actually got a topic
if (jmsOutgoingTopic == null) {
- throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
+ throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
+ "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
index 82c3cf331..5556d0310 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
@@ -85,8 +85,8 @@ public class ApexRestClientProducer implements ApexEventProducer {
restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD);
}
- if (!restProducerProperties.getHttpMethod().equalsIgnoreCase("POST")
- && !restProducerProperties.getHttpMethod().equalsIgnoreCase("PUT")) {
+ if (!"POST".equalsIgnoreCase(restProducerProperties.getHttpMethod())
+ && !"PUT".equalsIgnoreCase(restProducerProperties.getHttpMethod())) {
final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod()
+ "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
+ "for event sending on REST client producer (" + this.name + ")";
@@ -183,7 +183,7 @@ public class ApexRestClientProducer implements ApexEventProducer {
*/
public Response sendEventAsRestRequest(final String event) {
// We have already checked that it is a PUT or POST request
- if (restProducerProperties.getHttpMethod().equalsIgnoreCase("POST")) {
+ if ("POST".equalsIgnoreCase(restProducerProperties.getHttpMethod())) {
return client.target(restProducerProperties.getUrl()).request("application/json").post(Entity.json(event));
} else {
return client.target(restProducerProperties.getUrl()).request("application/json").put(Entity.json(event));
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java
index 9e9024401..aaccbebab 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java
@@ -89,7 +89,7 @@ public class JrubyStateFinalizerExecutor extends StateFinalizerExecutor {
boolean returnValue = false;
final IRubyObject ret = parsedjruby.run();
if (ret != null) {
- final Boolean retbool = (Boolean) ret.toJava(java.lang.Boolean.class);
+ final Boolean retbool = ret.toJava(java.lang.Boolean.class);
if (retbool != null) {
returnValue = true;
}
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
index d49423486..8019259bd 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
@@ -89,7 +89,7 @@ public class JrubyTaskExecutor extends TaskExecutor {
boolean returnValue = false;
final IRubyObject ret = parsedjruby.run();
if (ret != null) {
- final Boolean retbool = (Boolean) ret.toJava(java.lang.Boolean.class);
+ final Boolean retbool = ret.toJava(java.lang.Boolean.class);
if (retbool != null) {
returnValue = true;
}
diff --git a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java
index b3ce7e0fd..0e239f7bc 100644
--- a/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java
@@ -90,7 +90,7 @@ public class JrubyTaskSelectExecutor extends TaskSelectExecutor {
boolean returnValue = false;
final IRubyObject ret = parsedjruby.run();
if (ret != null) {
- final Boolean retbool = (Boolean) ret.toJava(java.lang.Boolean.class);
+ final Boolean retbool = ret.toJava(java.lang.Boolean.class);
if (retbool != null) {
returnValue = true;
}