Fix some pmd high priority errors
Change-Id: Ieb38cdbe1dd2c47515976850b7e5edf8c35674da
diff --git a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java
index e568e09..ee7d862 100644
--- a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java
+++ b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java
@@ -111,7 +111,7 @@
// intentionally throwing Exception "e" thrown from non-fallback
// Hazelcast configuration loading.
- throw new Error("Cannot find Hazelcast configuration: " + hazelcastConfigFileName, e);
+ throw new IllegalStateException("Cannot find Hazelcast configuration: " + hazelcastConfigFileName, e);
}
}
diff --git a/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java b/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java
index f3ba0c5..4d9d4ef 100644
--- a/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java
+++ b/src/main/java/net/onrc/onos/core/intent/ConstrainedBFSTree.java
@@ -52,7 +52,7 @@
/**
* Calculates the BFS tree using any provided constraints and Intents.
*/
- protected void calcTree() {
+ protected final void calcTree() {
switchQueue.add(rootSwitch);
switchSearched.add(rootSwitch.getDpid());
while (!switchQueue.isEmpty()) {
diff --git a/src/main/java/net/onrc/onos/core/intent/FlowEntry.java b/src/main/java/net/onrc/onos/core/intent/FlowEntry.java
index 0fd618e..2307e65 100644
--- a/src/main/java/net/onrc/onos/core/intent/FlowEntry.java
+++ b/src/main/java/net/onrc/onos/core/intent/FlowEntry.java
@@ -244,7 +244,7 @@
* Generates hash using Objects.hash() on the match and actions.
*/
@Override
- public int hashCode() {
+ public final int hashCode() {
return Objects.hash(match, actions);
}
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/PersistIntent.java b/src/main/java/net/onrc/onos/core/intent/runtime/PersistIntent.java
index d1076ed..14a0534 100644
--- a/src/main/java/net/onrc/onos/core/intent/runtime/PersistIntent.java
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/PersistIntent.java
@@ -91,23 +91,24 @@
public boolean persistIfLeader(long key, IntentOperationList operations) {
boolean leader = true;
boolean ret = false;
+ long keyValue = key;
// TODO call controllerRegistry.isClusterLeader()
if (leader) {
try {
// reserve key 10 entries for multi-write if size over 1MB
- key *= 10;
+ keyValue *= 10;
kryo.writeObject(output, operations);
output.close();
- ByteBuffer keyBytes = ByteBuffer.allocate(8).putLong(key);
+ ByteBuffer keyBytes = ByteBuffer.allocate(8).putLong(keyValue);
byte[] buffer = stream.toByteArray();
int total = buffer.length;
if ((total >= VALUE_STORE_LIMIT)) {
int writeCount = total / VALUE_STORE_LIMIT;
int remainder = total % VALUE_STORE_LIMIT;
int upperIndex = 0;
- for (int i = 0; i < writeCount; i++, key++) {
+ for (int i = 0; i < writeCount; i++, keyValue++) {
keyBytes.clear();
- keyBytes.putLong(key);
+ keyBytes.putLong(keyValue);
keyBytes.flip();
upperIndex = (i * VALUE_STORE_LIMIT + VALUE_STORE_LIMIT) - 1;
log.debug("writing using indexes {}:{}", (i * VALUE_STORE_LIMIT), upperIndex);
@@ -115,7 +116,7 @@
}
if (remainder > 0) {
keyBytes.clear();
- keyBytes.putLong(key);
+ keyBytes.putLong(keyValue);
keyBytes.flip();
log.debug("writing using indexes {}:{}", upperIndex, total);
table.create(keyBytes.array(), Arrays.copyOfRange(buffer, upperIndex + 1, total - 1));
@@ -124,13 +125,13 @@
keyBytes.flip();
table.create(keyBytes.array(), buffer);
}
- log.debug("key is {} value length is {}", key, buffer.length);
+ log.debug("key is {} value length is {}", keyValue, buffer.length);
stream.reset();
stream.close();
log.debug("persist operations to ramcloud size of operations: {}", operations.size());
ret = true;
} catch (ObjectExistsException ex) {
- log.warn("Failed to store intent journal with key " + key);
+ log.warn("Failed to store intent journal with key " + keyValue);
} catch (IOException ex) {
log.error("Failed to close the stream");
}