summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-02-23 17:17:45 -0800
committerElliott Hughes <enh@google.com>2011-02-23 17:17:45 -0800
commit685f9f54501631ef05a9379fa865004dc33a2ae5 (patch)
treeacd63f128896f76ca6d04e2823ffe5e13257ab75 /luni
parent9ebb5807fa40f3bddf3567906a2c77ee053174bb (diff)
downloadlibcore-685f9f54501631ef05a9379fa865004dc33a2ae5.zip
libcore-685f9f54501631ef05a9379fa865004dc33a2ae5.tar.gz
libcore-685f9f54501631ef05a9379fa865004dc33a2ae5.tar.bz2
More FindBugs complaints in ObjectInputStream.
I don't know why there was so much bogus (too late) null checking in this code, but it's not obvious how fieldDesc could ever be null, so I think that removing the checks rather than fixing them is the right resolution. Change-Id: I72ee5c048ddebc3678c94f23e4c09dcb2790dfc7
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/java/io/ObjectInputStream.java41
1 files changed, 15 insertions, 26 deletions
diff --git a/luni/src/main/java/java/io/ObjectInputStream.java b/luni/src/main/java/java/io/ObjectInputStream.java
index cc0c6ec..91162e2 100644
--- a/luni/src/main/java/java/io/ObjectInputStream.java
+++ b/luni/src/main/java/java/io/ObjectInputStream.java
@@ -1135,32 +1135,21 @@ public class ObjectInputStream extends InputStream implements ObjectInput, Objec
field.setBoolean(obj, z);
}
} else {
- boolean setBack = false;
- if (mustResolve && fieldDesc == null) {
- setBack = true;
- mustResolve = false;
- }
- boolean unshared = fieldDesc != null && fieldDesc.isUnshared();
- Object toSet = unshared ? readUnshared() : readObject();
- if (setBack) {
- mustResolve = true;
- }
- if (fieldDesc != null) {
- if (toSet != null) {
- // Get the field type from the local field rather than
- // from the stream's supplied data. That's the field
- // we'll be setting, so that's the one that needs to be
- // validated.
- String fieldName = fieldDesc.getName();
- ObjectStreamField localFieldDesc = classDesc.getField(fieldName);
- Class<?> fieldType = localFieldDesc.getTypeInternal();
- Class<?> valueType = toSet.getClass();
- if (!fieldType.isAssignableFrom(valueType)) {
- throw new ClassCastException(classDesc.getName() + "." + fieldName + " - " + fieldType + " not compatible with " + valueType);
- }
- if (field != null) {
- field.set(obj, toSet);
- }
+ Object toSet = fieldDesc.isUnshared() ? readUnshared() : readObject();
+ if (toSet != null) {
+ // Get the field type from the local field rather than
+ // from the stream's supplied data. That's the field
+ // we'll be setting, so that's the one that needs to be
+ // validated.
+ String fieldName = fieldDesc.getName();
+ ObjectStreamField localFieldDesc = classDesc.getField(fieldName);
+ Class<?> fieldType = localFieldDesc.getTypeInternal();
+ Class<?> valueType = toSet.getClass();
+ if (!fieldType.isAssignableFrom(valueType)) {
+ throw new ClassCastException(classDesc.getName() + "." + fieldName + " - " + fieldType + " not compatible with " + valueType);
+ }
+ if (field != null) {
+ field.set(obj, toSet);
}
}
}