twitter / Serial

Light-weight, fast framework for object serialization in Java, with Android support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't deserialize - Unknown type 26

Tapchicoma opened this issue · comments

I've implemented pretty simple ObjectSerializer and getting following exception after killing/restarting the app:

 Got exception: com.twitter.serial.util.SerializationException: Expected value of type string but found unknown (26).
                                                                  com.twitter.serial.util.SerializationException: Expected value of type string but found unknown (26).
                                                                      at com.twitter.serial.stream.bytebuffer.ByteBufferSerializerInput.reportUnexpectedHeader(ByteBufferSerializerInput.java:221)
                                                                      at com.twitter.serial.stream.bytebuffer.ByteBufferSerializerInput.readString(ByteBufferSerializerInput.java:117)
                                                                      at org.moire.ultrasonic.cache.serializers.DomainSerializers__ArtistSerializerKt$artistSerializer$1.deserializeObject(ArtistSerializer.kt:44)
                                                                      at org.moire.ultrasonic.cache.serializers.DomainSerializers__ArtistSerializerKt$artistSerializer$1.deserializeObject(ArtistSerializer.kt:18)
                                                                      at com.twitter.serial.serializer.ObjectSerializer.deserialize(ObjectSerializer.java:88)
                                                                      at com.twitter.serial.serializer.CollectionSerializers.deserializeList(CollectionSerializers.java:134)
                                                                      at com.twitter.serial.serializer.CollectionSerializers.access$100(CollectionSerializers.java:38)
                                                                      at com.twitter.serial.serializer.CollectionSerializers$1.deserializeObject(CollectionSerializers.java:57)
                                                                      at com.twitter.serial.serializer.CollectionSerializers$1.deserializeObject(CollectionSerializers.java:46)
                                                                      at com.twitter.serial.serializer.ObjectSerializer.deserialize(ObjectSerializer.java:88)
                                                                      at com.twitter.serial.stream.SerializerInput.readObject(SerializerInput.java:62)
                                                                      at org.moire.ultrasonic.cache.serializers.DomainSerializers__IndexesSerializerKt$indexesSerializer$1.deserializeObject(IndexesSerializer.kt:40)
                                                                      at org.moire.ultrasonic.cache.serializers.DomainSerializers__IndexesSerializerKt$indexesSerializer$1.deserializeObject(IndexesSerializer.kt:15)
                                                                      at com.twitter.serial.serializer.ObjectSerializer.deserialize(ObjectSerializer.java:88)
                                                                      at com.twitter.serial.stream.bytebuffer.ByteBufferSerial.fromByteArray(ByteBufferSerial.java:107)
                                                                      at org.moire.ultrasonic.cache.PermanentFileStorage.load(PermanentFileStorage.kt:54)
                                                                      at org.moire.ultrasonic.service.RESTMusicService.getIndexes(RESTMusicService.java:181)
                                                                      at org.moire.ultrasonic.service.CachedMusicService.getIndexes(CachedMusicService.java:135)
                                                                      at org.moire.ultrasonic.activity.SelectArtistActivity$2.doInBackground(SelectArtistActivity.java:160)
                                                                      at org.moire.ultrasonic.activity.SelectArtistActivity$2.doInBackground(SelectArtistActivity.java:143)
                                                                      at org.moire.ultrasonic.util.TabActivityBackgroundTask$1.run(TabActivityBackgroundTask.java:37)

I've looked into SerializerDefs and, indeed, can't find such type.

Here is serialized file: failed.zip

Hey @Tapchicoma, the format of your file is valid, and I can dump it without trouble (using our internal SerializationUtils. dumpSerializedData()). Looking at the binary data, there's a 26 in two positions, but the format of the file around it looks fine as well.

The input stream should never attempt to read a header in the wrong place, so there's certainly a bug. It would be helpful if you could walk through the deserialization and figure out the sequence of steps that takes to this issue. Otherwise, I can help debug if I can repro myself. What would be the best way to do that?

Hi @cesar1000. You can see implementation details in this PR: ultrasonic/ultrasonic#173

Especially take a look on this two serializers: IndexesSerailizer.kt and ArtistsSerializer.kt. Error happens when app tries to deserailize Indexes.

Thanks for the report, @Tapchicoma! This was my bad: the code I used diverged slightly from our internal version, so I had to set up a project to repro. I threw in some extra debugging code that should make it simpler to diagnose this kind of issue in the future.

@amandeepg, can you release a new version containing this fix?

Thanks, new version of the library works ok!

Awesome! Let us know if you have any questions or run into nay other issues :)