asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in hyracks[master]: Fixes for Coverity Issues
Date Wed, 24 Feb 2016 04:14:27 GMT
Till Westmann has submitted this change and it was merged.

Change subject: Fixes for Coverity Issues
......................................................................


Fixes for Coverity Issues

(https://scan.coverity.com/projects/hyracks)

- CID 68257 (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_resource: Variable outputStream going out of scope leaks the
 resource it refers to.
- CID 68260 (#1 of 1): Useless call (USELESS_CALL)
side_effect_free: Calling equivalentVars.get(0) is only useful for its
 return value, which is ignored.
- CID 68261 (#1 of 1): BC: Bad casts of object references
 (FB.BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS)
1. defect: Equals method for org.apache.hyracks.algebricks.core.
algebra.properties.LocalOrderProperty assumes the argument is of type
 LocalOrderProperty.
- CID 68262 (#1 of 1): BC: Bad casts of object references
(FB.BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS)
1. defect: Equals method for org.apache.hyracks.storage.am.rtree.
RTreeCheckTuple assumes the argument is of type RTreeCheckTuple.

Change-Id: I8ba6e578f173b1081a8f55b228704744f08588df
Reviewed-on: https://asterix-gerrit.ics.uci.edu/658
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Reviewed-by: Till Westmann <tillw@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
---
M algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/LocalOrderProperty.java
M algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
M hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/file/RecordWriter.java
M hyracks/hyracks-test-support/src/main/java/org/apache/hyracks/storage/am/rtree/RTreeCheckTuple.java
4 files changed, 17 insertions(+), 10 deletions(-)

Approvals:
  Yingyi Bu: Looks good to me, approved
  Till Westmann: Looks good to me, approved
  Jenkins: Verified



diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/LocalOrderProperty.java
b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/LocalOrderProperty.java
index d1d0ca9..6b39a8d 100644
--- a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/LocalOrderProperty.java
+++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/LocalOrderProperty.java
@@ -84,8 +84,12 @@
 
     @Override
     public boolean equals(Object object) {
-        LocalOrderProperty lop = (LocalOrderProperty) object;
-        return orderColumns.equals(lop.orderColumns);
+        if (object instanceof LocalOrderProperty) {
+            LocalOrderProperty lop = (LocalOrderProperty) object;
+            return orderColumns.equals(lop.orderColumns);
+        } else {
+            return false;
+        }
     }
 
     /**
diff --git a/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
b/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
index 9e867df..eb72db0 100644
--- a/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
+++ b/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
@@ -100,7 +100,6 @@
             equivalentVarsMap.put(rhs, equivalentVars);
         }
         equivalentVarsMap.put(lhs, equivalentVars);
-        equivalentVars.get(0);
     }
 
     private boolean removeRedundantVariables(Mutable<ILogicalOperator> opRef, IOptimizationContext
context)
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/file/RecordWriter.java
b/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/file/RecordWriter.java
index 1d45b22..2f6b53e 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/file/RecordWriter.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/file/RecordWriter.java
@@ -36,7 +36,7 @@
     public RecordWriter(Object[] args) throws Exception {
         OutputStream outputStream = createOutputStream(args);
         if (outputStream != null) {
-            bufferedWriter = new BufferedWriter(new OutputStreamWriter(createOutputStream(args)));
+            bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
         } else {
             bufferedWriter = null;
         }
diff --git a/hyracks/hyracks-test-support/src/main/java/org/apache/hyracks/storage/am/rtree/RTreeCheckTuple.java
b/hyracks/hyracks-test-support/src/main/java/org/apache/hyracks/storage/am/rtree/RTreeCheckTuple.java
index 160e25c..4f7066f 100644
--- a/hyracks/hyracks-test-support/src/main/java/org/apache/hyracks/storage/am/rtree/RTreeCheckTuple.java
+++ b/hyracks/hyracks-test-support/src/main/java/org/apache/hyracks/storage/am/rtree/RTreeCheckTuple.java
@@ -30,14 +30,18 @@
 
     @Override
     public boolean equals(Object o) {
-        RTreeCheckTuple<T> other = (RTreeCheckTuple<T>) o;
-        for (int i = 0; i < fields.length; i++) {
-            int cmp = fields[i].compareTo(other.getField(i));
-            if (cmp != 0) {
-                return false;
+        if (o instanceof RTreeCheckTuple) {
+            RTreeCheckTuple<T> other = (RTreeCheckTuple<T>) o;
+            for (int i = 0; i < fields.length; i++) {
+                int cmp = fields[i].compareTo(other.getField(i));
+                if (cmp != 0) {
+                    return false;
+                }
             }
+            return true;
+        } else {
+            return false;
         }
-        return true;
     }
 
     public boolean intersect(T o) {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/658
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8ba6e578f173b1081a8f55b228704744f08588df
Gerrit-PatchSet: 3
Gerrit-Project: hyracks
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <michael.blow@couchbase.com>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <tillw@apache.org>
Gerrit-Reviewer: Yingyi Bu <buyingyi@gmail.com>

Mime
View raw message