mirror of
https://github.com/lightbend/config.git
synced 2025-02-23 09:41:01 +08:00
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:
parent
db3a676c02
commit
aea95bd228
@ -71,6 +71,7 @@ public final class ConfigParseOptions {
|
||||
* @return options with the origin description set
|
||||
*/
|
||||
public ConfigParseOptions setOriginDescription(String originDescription) {
|
||||
// findbugs complains about == here but is wrong, do not "fix"
|
||||
if (this.originDescription == originDescription)
|
||||
return this;
|
||||
else if (this.originDescription != null && originDescription != null
|
||||
|
@ -58,7 +58,7 @@ abstract class ConfigNumber extends AbstractConfigValue implements Serializable
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
// note that "origin" is deliberately NOT part of equality
|
||||
if (canEqual(other)) {
|
||||
if (other instanceof ConfigNumber && canEqual(other)) {
|
||||
ConfigNumber n = (ConfigNumber) other;
|
||||
if (isWhole()) {
|
||||
return n.isWhole() && this.longValue() == n.longValue();
|
||||
|
@ -48,7 +48,7 @@ final class ResolveSource {
|
||||
context.untrace();
|
||||
context.trace(unprefixed);
|
||||
|
||||
if (result == null && prefixLength > 0) {
|
||||
if (prefixLength > 0) {
|
||||
result = findInObject(root, context, unprefixed);
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,13 @@ class SerializedConfigValue extends AbstractConfigValue implements Externalizabl
|
||||
|
||||
private static void skipField(DataInput in) throws IOException {
|
||||
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
|
||||
|
@ -504,7 +504,7 @@ final class Tokenizer {
|
||||
lineOrigin = origin.setLineNumber(lineNumber);
|
||||
return line;
|
||||
} else {
|
||||
Token t = null;
|
||||
Token t;
|
||||
if (startOfComment(c)) {
|
||||
t = pullComment(c);
|
||||
} else {
|
||||
@ -539,6 +539,9 @@ final class Tokenizer {
|
||||
case '+':
|
||||
t = pullPlusEquals();
|
||||
break;
|
||||
default:
|
||||
t = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (t == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user