Code Monkey home page Code Monkey logo

Comments (5)

iamironz avatar iamironz commented on May 25, 2024

Hi! What version of library do you use?
Also one question: what key you use for fetching Persistable from preferences?
It looks like registered Persistable object key differs with key witch has been passed into getPersistable method.

from binaryprefs.

iamironz avatar iamironz commented on May 25, 2024

As you can see this code part tries to fetch registered Persistable class type for instantiation and deserialization of stored binary data and in your case it just not found after getPersistable invocation because your key from getPersistable does not found inside PersistableRegistry map structure.

from binaryprefs.

iamironz avatar iamironz commented on May 25, 2024

I can recommend disable all encryption for checking how works simple fetching. Because most of problems is incorrect custom key/value encryption. Also I recommend to use bundled encryption algorithms and different keys for each of.

from binaryprefs.

huzzoid avatar huzzoid commented on May 25, 2024

The original question based on 1.0.0-BETA-2.
Also i have tried 0.9.9.9, and caught another exception:

Caused by: com.ironz.binaryprefs.exception.FileOperationException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Can't read out of bounds array (71 bytes > 62 bytes). May be your read/write contract isn't mirror-implemented?
                                                                            at com.ironz.binaryprefs.task.Completable.completeBlockingUnsafe(Completable.java:44)
                                                                            at com.ironz.binaryprefs.BinaryPreferences.fetchCache(BinaryPreferences.java:60)
                                                                            at com.ironz.binaryprefs.BinaryPreferences.<init>(BinaryPreferences.java:40)
                                                                            at com.ironz.binaryprefs.BinaryPreferencesBuilder.build(BinaryPreferencesBuilder.java:205)

There is getting of my encription keys (this part has never been changed since first implementation):

private val INITIAL_VECTOR = "be or not to be that is the question".toByteArray()
private val SECRET_KEY = "be or not to be that is the question".toByteArray()

 val initialVector = Arrays.copyOf(INITIAL_VECTOR, 16)
  val secretKey = Arrays.copyOf(SECRET_KEY, 16)
  
BinaryPreferencesBuilder(context)
            .keyEncryption(XorKeyEncryptionImpl(secretKey))
            .valueEncryption(AesValueEncryptionImpl(secretKey, initialVector))

My experiment with disabled encription:

Caused by: com.ironz.binaryprefs.exception.FileOperationException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Can't read out of bounds array (expected size: LogoPass bytes > disk size: 71 bytes) for 62! keyMay be your read/write contract isn't mirror-implemented or old disk version is not backward compatible with new class version?
                                                                            at com.ironz.binaryprefs.task.FutureBarrier.completeBlockingUnsafe(FutureBarrier.java:44)
                                                                            at com.ironz.binaryprefs.BinaryPreferences.fetchCache(BinaryPreferences.java:52)
                                                                            at com.ironz.binaryprefs.BinaryPreferences.<init>(BinaryPreferences.java:40)
                                                                            at com.ironz.binaryprefs.BinaryPreferencesBuilder.createInstance(BinaryPreferencesBuilder.java:251)
                                                                            at com.ironz.binaryprefs.BinaryPreferencesBuilder.build(BinaryPreferencesBuilder.java:226)

As i can see there is migration required, but i'm not sure how to do it correctly. What is "old preferences" and "new preferences" at the docs?

from binaryprefs.

iamironz avatar iamironz commented on May 25, 2024

"old" - disk version means your old saving protocol for first version of Persistable.
"new" - means actual protocol which tries restore old saved data based on your first protocol version.
If you wanna to use migration for your Persistable you should follow mutual steps as in java.io.Externalizable interface. Read manuals about it.

from binaryprefs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.