Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ayush
    @ayushworks
    kryo.newInstance(type) with type as scala.collection.convert.Wrappers$MapWrapper returns an exception
    santhoshkumar
    @santhoshTpixler
    When can we expect the version 5 release?
    Martin Grotzke
    @magro
    Hey @santhoshTpixler, sorry for the late response. Right now there's some activity to push things forward, which is a good thing 😊 Because there's a quite big change bringing kryo5 as an additional self contained artifact (for usage in other libs, not applications), I'd rather publish another RC before a final release. Thanks for your patience 🙂
    Martin Grotzke
    @magro
    Bhavesh Mistry
    @bmistry13
    Hello All, I need to Store Hibernate Entities with Lazy loading into Hazelcast, How do I do that ?
    Is there any example ?
    Bhavesh Mistry
    @bmistry13
    hi
    @magro , I have Lamda Supplier class, how to serialize them ?
    I posted issue: EsotericSoftware/kryo#714
    Bhavesh Mistry
    @bmistry13
    @magro , I was able to figure out and I have closed EsotericSoftware/kryo#714 issue with my findings.
    Thanks for all your great work.
    Niels
    @AFKspezi_twitter
    Is this a place where someone can help me with sending a SealedObject.
    I really need help for a school project.
    Martin Grotzke
    @magro
    @bmistry13 sorry, I missed your message here, great that you solved it!
    @AFKspezi_twitter Not sure what you mean with SealedObject. You can try to describe your question more detailed here and see if someone can help. You could also write to the mailing list / google group.
    Martin Grotzke
    @magro
    @AFKspezi_twitter If you experience issues with the (de)serialization of a certain object/class, you might have to write a specific serializer for it. You might check if this class has internal support for java serialization, and "translate" this to your kryo serializer for it. Alternatively you could register the JavaSerializer (not sure about the exact name) for the class.
    Niels
    @AFKspezi_twitter
    Thanks @magro for the answer. Yes I have issues with (de)serialization, but only when sending a secound Object. The first works fine. Is this a known issue? Yes I´m using the JavaSerializner.
    Niels
    @AFKspezi_twitter
    just for clarification, when I´m sending a SealedObject the first time it works perfectly. But when sending a secound SealedObject I get a "deserialization" Error.
    Martin Grotzke
    @magro
    These issues are most often very specific issues. You could submit a github issue with a minimal self contained reproducer - maybe someone can help.
    Niels
    @AFKspezi_twitter
    OK I figuerd it out. On registration I used kryo.register(javax.crypto.SealedObject.class,new JavaSerializer()); But because SealedObjects are encrypted I needed DeflateSerializer(new JavaSerializer()).
    Thanks anyways
    Martin Grotzke
    @magro
    @AFKspezi_twitter great that you solved it!
    mrthaggar
    @mrthaggar
    Hi all, I've got a file that's been serialised using Kryo, unfortunately I don't have access to the source code, or class definitions. Is there any documentation on how the actual bytes are written to the file? e.g the file starts with 0x 01 00, then the string 'java.util.Hashma' (the final p is 0x80 higher, which I guess is a checksum/terminator?)
    Martin Grotzke
    @magro
    Hi @mrthaggar, I'm sorry, but there's no documentation of the binary format.
    Bhavesh Mistry
    @bmistry13
    hi
    How do I serialize HibernateProxy and PersistentCollection classes
    To prevent lazy loading I am initializing
    But I wanted to know how to create custom serializer that just clean Proxy and use exiting serializer to serialize object
    I had to hack ObjectField
            /**** FIX FOR HIBERNATE OBJECT */
            if (PersistenceUtils.isProxy(value)){
                if(!Hibernate.isInitialized(value)){
                    if (INFO)
                        info("kryo", "uninitialized hibernate proxy detected  and initializing: " + this + " (" + object.getClass().getName() + ")" + " pos=" + output.position());
                    Hibernate.initialize(value);
                }
                value = PersistenceUtils.cleanFromProxies(value);
                if (INFO)
                    info("kryo", "Write field detected hibernate proxy and unproxying: " + this + " (" + object.getClass().getName() + ")" + " pos=" + output.position());
            }
    
            /****END  OF FIX *****/
    So I do this outside of ObjectField class
    I would appreciate any help or pointer
    Bhavesh Mistry
    @bmistry13
    @magro It same exact issue EsotericSoftware/kryo#580
    @magro "can't you write a serializer to handle this? The serializer could detect if it's a proxy object, get the implementation, and hand it off to another serializer" Do you have an example of wrapper serialization which will effectively do above and call other serializer?
    Each of Hibernate Entity is HibernateProxy or PersistentCollection
    Then we can unwrap the collection and load actual value and then serialize it
    Bhavesh Mistry
    @bmistry13
    PersistenceUtils unwraps collection into List or Set or Collection
    Thomas Heigl
    @theigl
    @bmistry13 : you can create a custom serializer for Hibernate proxies and persistent collections and unwrap the proxy in the write method
    e.g.
     kryoSerializer = new Kryo() { 
        @Override 
        public Serializer<?> getDefaultSerializer( final Class type ) { 
          if (AbstractPersistentCollection.class.isAssignableFrom( type )) { 
            return new FieldSerializer( kryoSerializer, type ); 
          } 
          return super.getDefaultSerializer( type ); 
        } 
      }
    something along those lines. and then override the write method of the serializer and unwrap the proxy before calling super.write
    payne911
    @payne911
    hi guys
    How does KryoNet work with Java 14's records?
    I'm getting:
    com.esotericsoftware.kryonet.KryoNetException: Error during deserialization.
    Caused by: com.esotericsoftware.kryo.KryoException: Class cannot be created (missing no-arg constructor): ...
    payne911
    @payne911
    Patrik Mihalcin
    @pmihalcin

    Hi all
    I'm dealing with thread safety of Kryo, Input and Output instances. I use com.esotericsoftware:kryo:4.0.2 and Kryo 4 doesn't offer API for pooling of Input and Output instances..

    how do you make Kryo, Input and Output instances thread safe using Kryo 4?

    Patrik Mihalcin
    @pmihalcin

    my take on this is:

    public class KryoSerializer {
    
        private static final KryoFactory factory = () -> {
            Kryo kryo = new Kryo();
            return kryo;
        };
        private static final KryoPool pool = new KryoPool.Builder(factory)
                .softReferences()
                .build();
    
        public byte[] serialize(Object object) {
            Output output = new Output(new ByteArrayOutputStream());
            Kryo kryo = pool.borrow();
            kryo.writeClassAndObject(output, object);
            output.close();
            pool.release(kryo);
            return output.getBuffer();
        }
    
        public Object deserialize(byte[] byteArray) {
            Input input = new Input(byteArray);
            Kryo kryo = pool.borrow();
            Object object = kryo.readClassAndObject(input);
            input.close();
            pool.release(kryo);
            return object;
        }
    }

    Do you see any problem with this implementation?

    Martin Grotzke
    @magro
    @pmihalcin basically this LGTM. IMHO you could/should use try/finally so that the Kryo instance is also released in case of exceptions.
    Following the first option shown in https://github.com/EsotericSoftware/kryo/tree/kryo-4#pooling-kryo-instances, you could pool Input/Output using ThreadLocals. Just make sure to reset them after usage.
    Nicholas Nezis
    @nicknezis
    What is the benefit to creating an ArrayListSerializer like this? Is ArrayList not already covered by the built-in serializers?
    https://github.com/apache/incubator-heron/blob/9d4541b34969fb871754086827544e0c6779c27e/heron/api/src/java/org/apache/heron/api/serializer/KryoSerializer.java#L221
    I'm looking to upgrade this project from 3.0.3 to 5.0.0-RC7, but wasn't sure if these serializers were still needed. If so, what would I need to change to support the newer version of Kryo?
    Žygimantas Gatelis
    @zygisx
    Hi, i have noticed that from version 5 KryoPool class is not included anymore. Couldn't find anything in migration guide either: https://github.com/EsotericSoftware/kryo/wiki/Migration-to-v5
    Maybe someone could guide me where i can find replacement for it ?
    Thomas Heigl
    @theigl
    @zygisx: Pooling now works slightly differently: https://github.com/EsotericSoftware/kryo#pooling