Browse Source

false positives for null dereferences

master
Stefan Bodewig 8 years ago
parent
commit
e1f9674ab3
3 changed files with 14 additions and 7 deletions
  1. +2
    -1
      src/main/org/apache/tools/ant/UnknownElement.java
  2. +9
    -3
      src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
  3. +3
    -3
      src/main/org/apache/tools/zip/ZipFile.java

+ 2
- 1
src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -646,7 +646,8 @@ public class UnknownElement extends Task {
return false;
}
for (int i = 0; i < childrenSize; ++i) {
UnknownElement child = (UnknownElement) children.get(i);
// children cannot be null childrenSize would have been 0
UnknownElement child = (UnknownElement) children.get(i); //NOSONAR
if (!child.similar(other.children.get(i))) {
return false;
}


+ 9
- 3
src/main/org/apache/tools/ant/taskdefs/MacroInstance.java View File

@@ -197,9 +197,12 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain
}
break;
case STATE_EXPECT_NAME:
// macroName cannot be null as this state is only
// ever reached from STATE_EXPECT_BRACKET after it
// has been set
if (ch == '}') {
state = STATE_NORMAL;
String name = macroName.toString().toLowerCase(Locale.ENGLISH);
String name = macroName.toString().toLowerCase(Locale.ENGLISH); //NOSONAR
String value = (String) macroMapping.get(name);
if (value == null) {
ret.append("@{");
@@ -210,7 +213,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain
}
macroName = null;
} else {
macroName.append(ch);
macroName.append(ch); //NOSONAR
}
break;
default:
@@ -224,8 +227,11 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain
ret.append('@');
break;
case STATE_EXPECT_NAME:
// macroName cannot be null as this state is only
// ever reached from STATE_EXPECT_BRACKET after it
// has been set
ret.append("@{");
ret.append(macroName.toString());
ret.append(macroName.toString()); //NOSONAR
break;
default:
break;


+ 3
- 3
src/main/org/apache/tools/zip/ZipFile.java View File

@@ -1038,12 +1038,12 @@ public class ZipFile implements Closeable {
@Override
public boolean equals(final Object other) {
if (super.equals(other)) {
// super.equals would return false if other were not an Entry
// super.equals would return false if other were null or not an Entry
final Entry otherEntry = (Entry) other;
return offsetEntry.headerOffset
== otherEntry.offsetEntry.headerOffset
== otherEntry.offsetEntry.headerOffset //NOSONAR
&& offsetEntry.dataOffset
== otherEntry.offsetEntry.dataOffset;
== otherEntry.offsetEntry.dataOffset; //NOSONAR
}
return false;
}


Loading…
Cancel
Save