tailorlala / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

NullPointerException in RegularImmutableList.equals() after Deserialization #1861

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Field "array" of class "RegularImmutableList" is marked as transient. So it 
gets null after deserialization. Method "equals(Object)" tries to access the 
array and a NullPointerException is thrown.

Original issue reported on code.google.com by gomarkus on 2 Oct 2014 at 11:55

GoogleCodeExporter commented 9 years ago
Can you actually demonstrate this case?

Serializing a RegularImmutableList should call ImmutableList.writeReplace(), 
which serializes as an ImmutableList.SerializedForm, which readResolve()s to a 
copyOf(Object[]) which should generate a normal RegularImmutableList again.

Original comment by lowas...@google.com on 2 Oct 2014 at 3:08

GoogleCodeExporter commented 9 years ago
I was unable to create a minimal working example, so it's more probably an 
issue in the pojo serializer of MapDB. Here is the stacktrace anyway:

java.lang.NullPointerException
    at com.google.common.collect.Iterators.forArray(Iterators.java:1042)
    at com.google.common.collect.RegularImmutableList.listIterator(RegularImmutableList.java:106)
    at com.google.common.collect.ImmutableList.listIterator(ImmutableList.java:344)
    at com.google.common.collect.ImmutableList.iterator(ImmutableList.java:340)
    at com.google.common.collect.ImmutableList.iterator(ImmutableList.java:61)
    at com.google.common.collect.Lists.equalsImpl(Lists.java:918)
    at com.google.common.collect.ImmutableList.equals(ImmutableList.java:567)
    at org.apache.commons.lang3.builder.EqualsBuilder.append(EqualsBuilder.java:465)
    at org.apache.commons.lang3.builder.EqualsBuilder.reflectionAppend(EqualsBuilder.java:411)
    at org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals(EqualsBuilder.java:360)
    at org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals(EqualsBuilder.java:271)
    at de.teckpro.fw.valueobject.RechnerValueObject.equals(RechnerValueObject.java:65)
    at org.apache.commons.lang3.builder.EqualsBuilder.append(EqualsBuilder.java:465)
    at org.apache.commons.lang3.builder.EqualsBuilder.reflectionAppend(EqualsBuilder.java:411)
    at org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals(EqualsBuilder.java:360)
    at org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals(EqualsBuilder.java:271)
    at de.teckpro.fw.valueobject.RechnerValueObject.equals(RechnerValueObject.java:65)
    at org.apache.commons.lang3.builder.EqualsBuilder.append(EqualsBuilder.java:465)
    at org.apache.commons.lang3.builder.EqualsBuilder.append(EqualsBuilder.java:655)
    at de.teckpro.aspekt.Cache$CacheKey.equals(Cache.aj:276)
    at org.mapdb.Hasher$1.equals(Hasher.java:42)
    at org.mapdb.HTreeMap.getInner(HTreeMap.java:452)
    at org.mapdb.HTreeMap.getPeek(HTreeMap.java:428)
    at org.mapdb.HTreeMap.containsKey(HTreeMap.java:300)

Original comment by gomarkus on 2 Oct 2014 at 7:43

GoogleCodeExporter commented 9 years ago
So it's another library doing the serialization? That sounds like the problem, 
if it respects some parts of the standard Java serialization scheme (like 
transient) but not others (like writeReplace and readResolve). We do have tests 
that check that our collections serialize and deserialize correctly.

Original comment by cgdecker@google.com on 3 Oct 2014 at 12:51

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07