fix some warnings from findbugs

Only one of these, possible incomplete skip
from DataInput.skipBytes(), was a real problem
I think.
This commit is contained in:
Havoc Pennington 2012-04-12 15:33:15 -04:00
parent db3a676c02
commit aea95bd228
5 changed files with 14 additions and 4 deletions

View File

@ -71,6 +71,7 @@ public final class ConfigParseOptions {
* @return options with the origin description set * @return options with the origin description set
*/ */
public ConfigParseOptions setOriginDescription(String originDescription) { public ConfigParseOptions setOriginDescription(String originDescription) {
// findbugs complains about == here but is wrong, do not "fix"
if (this.originDescription == originDescription) if (this.originDescription == originDescription)
return this; return this;
else if (this.originDescription != null && originDescription != null else if (this.originDescription != null && originDescription != null

View File

@ -58,7 +58,7 @@ abstract class ConfigNumber extends AbstractConfigValue implements Serializable
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
// note that "origin" is deliberately NOT part of equality // note that "origin" is deliberately NOT part of equality
if (canEqual(other)) { if (other instanceof ConfigNumber && canEqual(other)) {
ConfigNumber n = (ConfigNumber) other; ConfigNumber n = (ConfigNumber) other;
if (isWhole()) { if (isWhole()) {
return n.isWhole() && this.longValue() == n.longValue(); return n.isWhole() && this.longValue() == n.longValue();

View File

@ -48,7 +48,7 @@ final class ResolveSource {
context.untrace(); context.untrace();
context.trace(unprefixed); context.trace(unprefixed);
if (result == null && prefixLength > 0) { if (prefixLength > 0) {
result = findInObject(root, context, unprefixed); result = findInObject(root, context, unprefixed);
} }

View File

@ -418,7 +418,13 @@ class SerializedConfigValue extends AbstractConfigValue implements Externalizabl
private static void skipField(DataInput in) throws IOException { private static void skipField(DataInput in) throws IOException {
int len = in.readInt(); int len = in.readInt();
in.skipBytes(len); // skipBytes doesn't have to block
int skipped = in.skipBytes(len);
if (skipped < len) {
// wastefully use readFully() if skipBytes didn't work
byte[] bytes = new byte[(len - skipped)];
in.readFully(bytes);
}
} }
@Override @Override

View File

@ -504,7 +504,7 @@ final class Tokenizer {
lineOrigin = origin.setLineNumber(lineNumber); lineOrigin = origin.setLineNumber(lineNumber);
return line; return line;
} else { } else {
Token t = null; Token t;
if (startOfComment(c)) { if (startOfComment(c)) {
t = pullComment(c); t = pullComment(c);
} else { } else {
@ -539,6 +539,9 @@ final class Tokenizer {
case '+': case '+':
t = pullPlusEquals(); t = pullPlusEquals();
break; break;
default:
t = null;
break;
} }
if (t == null) { if (t == null) {