You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2017/07/09 01:43:36 UTC

[2/5] storm git commit: STORM-2503: Fix lgtm.com alerts on equality and comparison operations.

STORM-2503: Fix lgtm.com alerts on equality and comparison operations.

Fixes several alerts involving comparison operations
found at https://lgtm.com/projects/g/apache/storm/alerts.


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/0943bb64
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/0943bb64
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/0943bb64

Branch: refs/heads/1.1.x-branch
Commit: 0943bb6482355230b09fd79ff4dc05a449850742
Parents: b0628c9
Author: Aditya Sharad <ad...@semmle.com>
Authored: Mon Jun 5 03:33:16 2017 +0100
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Sun Jul 9 10:31:23 2017 +0900

----------------------------------------------------------------------
 .../src/jvm/org/apache/storm/starter/TransactionalWords.java | 2 +-
 .../org/apache/storm/daemon/supervisor/ReadClusterState.java | 2 +-
 .../strategies/scheduling/DefaultResourceAwareStrategy.java  | 8 ++++----
 .../trident/windowing/StoreBasedTridentWindowManager.java    | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/0943bb64/examples/storm-starter/src/jvm/org/apache/storm/starter/TransactionalWords.java
----------------------------------------------------------------------
diff --git a/examples/storm-starter/src/jvm/org/apache/storm/starter/TransactionalWords.java b/examples/storm-starter/src/jvm/org/apache/storm/starter/TransactionalWords.java
index 64689b0..f25113c 100644
--- a/examples/storm-starter/src/jvm/org/apache/storm/starter/TransactionalWords.java
+++ b/examples/storm-starter/src/jvm/org/apache/storm/starter/TransactionalWords.java
@@ -124,7 +124,7 @@ public class TransactionalWords {
       for (String key : _counts.keySet()) {
         CountValue val = COUNT_DATABASE.get(key);
         CountValue newVal;
-        if (val == null || !val.txid.equals(_id)) {
+        if (val == null || !val.txid.equals(_id.getTransactionId())) {
           newVal = new CountValue();
           newVal.txid = _id.getTransactionId();
           if (val != null) {

http://git-wip-us.apache.org/repos/asf/storm/blob/0943bb64/storm-core/src/jvm/org/apache/storm/daemon/supervisor/ReadClusterState.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/daemon/supervisor/ReadClusterState.java b/storm-core/src/jvm/org/apache/storm/daemon/supervisor/ReadClusterState.java
index 6ca9687..8fefe62 100644
--- a/storm-core/src/jvm/org/apache/storm/daemon/supervisor/ReadClusterState.java
+++ b/storm-core/src/jvm/org/apache/storm/daemon/supervisor/ReadClusterState.java
@@ -195,7 +195,7 @@ public class ReadClusterState implements Runnable, AutoCloseable {
             }
             if (version == null) {
                 // ignore
-            } else if (version == recordedVersion) {
+            } else if (version.equals(recordedVersion)) {
                 updateAssignmentVersion.put(topoId, locAssignment);
             } else {
                 VersionedData<Assignment> assignmentVersion = stormClusterState.assignmentInfoWithVersion(topoId, callback);

http://git-wip-us.apache.org/repos/asf/storm/blob/0943bb64/storm-core/src/jvm/org/apache/storm/scheduler/resource/strategies/scheduling/DefaultResourceAwareStrategy.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/scheduler/resource/strategies/scheduling/DefaultResourceAwareStrategy.java b/storm-core/src/jvm/org/apache/storm/scheduler/resource/strategies/scheduling/DefaultResourceAwareStrategy.java
index df3300c..5f81a72 100644
--- a/storm-core/src/jvm/org/apache/storm/scheduler/resource/strategies/scheduling/DefaultResourceAwareStrategy.java
+++ b/storm-core/src/jvm/org/apache/storm/scheduler/resource/strategies/scheduling/DefaultResourceAwareStrategy.java
@@ -521,7 +521,7 @@ public class DefaultResourceAwareStrategy implements IStrategy {
     }
 
     /**
-     * sort components by the number of in and out connections that need to be made
+     * sort components by the number of in and out connections that need to be made, in descending order
      *
      * @param componentMap The components that need to be sorted
      * @return a sorted set of components
@@ -541,7 +541,7 @@ public class DefaultResourceAwareStrategy implements IStrategy {
                     connections2 += (componentMap.get(childId).execs.size() * o2.execs.size());
                 }
 
-                if (connections1 > connections1) {
+                if (connections1 > connections2) {
                     return -1;
                 } else if (connections1 < connections2) {
                     return 1;
@@ -555,7 +555,7 @@ public class DefaultResourceAwareStrategy implements IStrategy {
     }
 
     /**
-     * Sort a component's neighbors by the number of connections it needs to make with this component
+     * Sort a component's neighbors by the number of connections it needs to make with this component, in descending order
      *
      * @param thisComp     the component that we need to sort its neighbors
      * @param componentMap all the components to sort
@@ -581,7 +581,7 @@ public class DefaultResourceAwareStrategy implements IStrategy {
     }
 
     /**
-     * Order executors based on how many in and out connections it will potentially need to make.
+     * Order executors based on how many in and out connections it will potentially need to make, in descending order.
      * First order components by the number of in and out connections it will have.  Then iterate through the sorted list of components.
      * For each component sort the neighbors of that component by how many connections it will have to make with that component.
      * Add an executor from this component and then from each neighboring component in sorted order.  Do this until there is nothing left to schedule

http://git-wip-us.apache.org/repos/asf/storm/blob/0943bb64/storm-core/src/jvm/org/apache/storm/trident/windowing/StoreBasedTridentWindowManager.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/trident/windowing/StoreBasedTridentWindowManager.java b/storm-core/src/jvm/org/apache/storm/trident/windowing/StoreBasedTridentWindowManager.java
index 87c1a0f..801a5f2 100644
--- a/storm-core/src/jvm/org/apache/storm/trident/windowing/StoreBasedTridentWindowManager.java
+++ b/storm-core/src/jvm/org/apache/storm/trident/windowing/StoreBasedTridentWindowManager.java
@@ -121,7 +121,7 @@ public class StoreBasedTridentWindowManager extends AbstractTridentWindowManager
         }
         String trimKey = key.substring(0, lastSepIndex);
         int secondLastSepIndex = trimKey.lastIndexOf(WindowsStore.KEY_SEPARATOR);
-        if (lastSepIndex < 0) {
+        if (secondLastSepIndex < 0) {
             throw new IllegalArgumentException("key "+key+" does not have second key separator '" + WindowsStore.KEY_SEPARATOR + "'");
         }