magro / kryo-serializers Goto Github PK
View Code? Open in Web Editor NEWMore kryo serializers
License: Apache License 2.0
More kryo serializers
License: Apache License 2.0
Hello
I have a field state(String), it was serialized. And then I change the state from String to Enum.How can I solve the deserialize problem?
THANKS!
This should be enough to reproduce it:
public final class ClassWithUnmodifieableList {
private List<String> names;
public ClassWithUnmodifieableList(String...names) {
this.names = Collections.unmodifiableList(Arrays.asList(names));
}
}
I'm getting this exception when attempting to deserialize this class:
com.hazelcast.nio.serialization.HazelcastSerializationException: com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
names (info.jerrinot.subzero.TestCustomerSerializers$ClassWithUnmodifieableList)
at com.hazelcast.internal.serialization.impl.SerializationUtil.handleException(SerializationUtil.java:61)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:178)
at com.hazelcast.map.impl.proxy.MapProxySupport.toObject(MapProxySupport.java:1067)
at com.hazelcast.map.impl.proxy.MapProxyImpl.get(MapProxyImpl.java:94)
at info.jerrinot.subzero.TestCustomerSerializers.testSpecialRegistrationRegisteredInDefaultConfigFile(TestCustomerSerializers.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
names (info.jerrinot.subzero.TestCustomerSerializers$ClassWithUnmodifieableList)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:144)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:540)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
at info.jerrinot.subzero.internal.strategy.GlobalKryoStrategy.readObject(GlobalKryoStrategy.java:28)
at info.jerrinot.subzero.internal.strategy.KryoStrategy.read(KryoStrategy.java:79)
at info.jerrinot.subzero.AbstractSerializer.read(AbstractSerializer.java:30)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:46)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:172)
... 32 more
Caused by: java.lang.NullPointerException
at java.util.Arrays$ArrayList.size(Arrays.java:3818)
at java.util.AbstractList.add(AbstractList.java:108)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
... 39 more
when I change it to
public ClassWithUnmodifieableList(String...names) {
ArrayList<String> strings = new ArrayList<>(names.length);
for (String name : names) {
strings.add(name);
}
this.names = Collections.unmodifiableList(strings);
}
then everything works as expected;
Kryo offers the possibility to configure a custom ClassLoader via Kryo.setClassLoader(ClassLoader classLoader), but Kryo-Serializers does not use it.
The fix is very simple, but I'm not familiar with Git, so I describe it here:
In JdkProxySerializer, line 38, where it is:
final ClassLoader classLoader = kryo.getClass().getClassLoader(); // TODO: can we do this?
I think it should be:
final ClassLoader classLoader = kryo.getClassLoader();
We use a custom ClassLoader in Android, and are trying to use Kryo to restore the Activity state after the app process is killed, but it's not possible for us to use the same ClassLoader to load Kryo.
Hi,
Although not commonly used, Patterns can have flags. I think the serializer should look like:
public void write(final Kryo kryo, final Output output, final Pattern pattern) {
output.writeString(pattern.pattern());
output.writeInt(pattern.flags(), true);
}
public Pattern read(final Kryo kryo, final Input input, final Class<Pattern> patternClass) {
String regex = input.readString();
int flags = input.readInt(true);
return Pattern.compile(regex, flags);
}
public class X {
private List xs = new ArrayList();
}
This is a hypothetical problem - I haven't personally a case that would be affected by this, but I can imagine that it could be a problem.
The serializer for Joda-Time DateTime tests if the associated time zone is the default time zone, and serializes that to en empty string. The deserializer, when it receives an empty string, then uses the default time zone on the receiving system.
This is duly documented in the comments: "If the time zone is the default time zone ({@link DateTimeZone#getDefault()}), the time zone attribute is omitted. This requires different machines to have the same time zone settings."
So if two machines in different time zones are communicating via Kryo and using Joda-Time DateTime with their time zones set to the default time zone, things are going to go wrong.
It can maybe be argued that you shouldn't use DateTime in that way. DateTime is more typically used with the time zone set to UTC, so then there isn't a problem. Except that maybe one of the machines is a server, and its time zone actually is set to UTC, so UTC the default for that system but not for the client systems.
My suggestion: remove that "optimization" and always send the time zone info. Or is is conceivable that some usage of this program is now dependent on this behavior, so doing that would be a "breaking change"?
Hi,
please release latest version of kryo-serializers that have support for guava's ImmutableList.
Hey,
I submitted a pull req some time ago to upgrade these serializers for Kryo 2. Is this project still active? I'd like to contribute more, but I don't see much movement.
It'd be great to be able to fold our serializers from https://github.com/Cascading/meat-locker into this project.
Sam
Oddly https://github.com/magro/kryo-serializers/blob/master/src/main/java/de/javakaffee/kryoserializers/guava/ImmutableSortedMapSerializer.java does not seem to be in the current maven version? There a reason for that?
When are we going to get a new release? It looks like there hasn't been one since October 2015. It would also be nice if you published snapshots to Sonatype.
I should test to figure out whether this is actually required or not. If fastutil serializes by default, then this ticket was a waste of your time.
interesting strategy, but works.
I see that there is support for guava's ImmutableSortedSet, but not UnmodifiableNavigableSet. Would be nice to have this with an easy to use recipe.
I'm using the EnumMapSerializer. if I put more than one entry in the map, the deserialization is broken. A single map entry works fine.
I've tried release 0.20 and 0.22-SNAPSHOT
The pom.xml says the following, the second line is wrong.
com.esotericsoftware.kryo_;version="[2.20,3.0)",
com.esotericsoftware.minlog_;version="[2.20,3.0)",
Does the latest release support Kryo 4.0.x? It explicitly states that it supports 2/3, but no mention of 4.
Hi all,
You still refer to the < 3.0 version of kryo in your osgi import statement - even if you have kryo 3.0 in your dependencies:
com.esotericsoftware.kryo*;version="[2.24.0,3.0)",
It would be great if you could fix this - i'll use a manually patched version in the meantime.
Thanks,
Mathias
Arrays.asList serializer doesn't properly support copy method, as simply returns original collection. But child elements of this collection are not immutable
Most of the builtin Predicates in guava's Predicates.java implement Serializable but are not serializable by Kryo by default. Please can there be a utility class which registers these as a block, e.g. Predicates.containsPattern(String).getClass(), etc.
2016-08-22 13:59:06,195 | ERROR | ult-dispatcher-2 | OneForOneStrategy | 172 - com.typesafe.akka.slf4j - 2.4.7 | java.util.ConcurrentModificationException
Serialization trace:
classes (sun.misc.Launcher$AppClassLoader)
parent (org.eclipse.core.runtime.internal.adaptor.ContextFinder)
contextClassLoader (java.lang.Thread)
threads (java.lang.ThreadGroup)
groups (java.lang.ThreadGroup)
group (org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
thread (org.eclipse.osgi.framework.eventmgr.EventManager)
bundleFileCloserManager (org.eclipse.osgi.baseadaptor.bundlefile.MRUBundleFileList)
mruList (org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile)
bundleFile (org.eclipse.osgi.internal.baseadaptor.SystemBundleData)
bundledata (org.eclipse.osgi.framework.internal.core.InternalSystemBundle)
bundle (org.eclipse.osgi.framework.internal.core.SystemBundleActivator)
activator (org.eclipse.osgi.framework.internal.core.BundleContextImpl)
context (org.eclipse.osgi.baseadaptor.BaseAdaptor)
adaptor (org.eclipse.osgi.baseadaptor.BaseData)
bundledata (org.eclipse.osgi.framework.internal.core.BundleHost)
bundle (org.eclipse.osgi.internal.loader.BundleLoader)
delegate (org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader)
referent (java.lang.ref.WeakReference)
clref (javassist.LoaderClassPath)
path (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
pathList (javassist.ClassPoolTail)
source (javassist.ClassPool)
classPool (org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils)
javassist (org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator)
generator (org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry)
registry (org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext)
factory (org.opendaylight.yangtools.binding.data.codec.impl.DataContainerCodecPrototype)
prototype (org.opendaylight.yangtools.binding.data.codec.impl.KeyedListNodeCodecContext)
context (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
cachedData (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
augmentation (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder$TerminationPointImpl)
input (org.opendaylight.newfederation.impl.DTOFederatedObject)
com.esotericsoftware.kryo.KryoException: java.util.ConcurrentModificationException
Serialization trace:
classes (sun.misc.Launcher$AppClassLoader)
parent (org.eclipse.core.runtime.internal.adaptor.ContextFinder)
contextClassLoader (java.lang.Thread)
threads (java.lang.ThreadGroup)
groups (java.lang.ThreadGroup)
group (org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
thread (org.eclipse.osgi.framework.eventmgr.EventManager)
bundleFileCloserManager (org.eclipse.osgi.baseadaptor.bundlefile.MRUBundleFileList)
mruList (org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile)
bundleFile (org.eclipse.osgi.internal.baseadaptor.SystemBundleData)
bundledata (org.eclipse.osgi.framework.internal.core.InternalSystemBundle)
bundle (org.eclipse.osgi.framework.internal.core.SystemBundleActivator)
activator (org.eclipse.osgi.framework.internal.core.BundleContextImpl)
context (org.eclipse.osgi.baseadaptor.BaseAdaptor)
adaptor (org.eclipse.osgi.baseadaptor.BaseData)
bundledata (org.eclipse.osgi.framework.internal.core.BundleHost)
bundle (org.eclipse.osgi.internal.loader.BundleLoader)
delegate (org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader)
referent (java.lang.ref.WeakReference)
clref (javassist.LoaderClassPath)
path (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
pathList (javassist.ClassPoolTail)
source (javassist.ClassPool)
classPool (org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils)
javassist (org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator)
generator (org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry)
registry (org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext)
factory (org.opendaylight.yangtools.binding.data.codec.impl.DataContainerCodecPrototype)
prototype (org.opendaylight.yangtools.binding.data.codec.impl.KeyedListNodeCodecContext)
context (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
cachedData (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
augmentation (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder$TerminationPointImpl)
input (org.opendaylight.newfederation.impl.DTOFederatedObject)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:101)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:366)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:307)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:366)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:307)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
.....
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at de.javakaffee.kryoserializers.JdkProxySerializer.write(JdkProxySerializer.java:52)[334:de.javakaffee.kryo-serializers:0.38.0]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.MapSerializer.write(MapSerializer.java:113)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.MapSerializer.write(MapSerializer.java:39)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at de.javakaffee.kryoserializers.JdkProxySerializer.write(JdkProxySerializer.java:52)[334:de.javakaffee.kryo-serializers:0.38.0]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.DefaultSerializers$CollectionsSingletonMapSerializer.write(DefaultSerializers.java:588)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.DefaultSerializers$CollectionsSingletonMapSerializer.write(DefaultSerializers.java:580)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:534)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at org.opendaylight.newfederation.transform.FederationPublisherActor.onReceive(FederationPublisherActor.java:53)[335:org.opendaylight.federation.new-federation:0.1.0.SNAPSHOT]
at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:165)[171:com.typesafe.akka.actor:2.4.7]
at akka.actor.Actor$class.aroundReceive(Actor.scala:484)[171:com.typesafe.akka.actor:2.4.7]
at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:95)[171:com.typesafe.akka.actor:2.4.7]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)[171:com.typesafe.akka.actor:2.4.7]
at akka.actor.ActorCell.invoke(ActorCell.scala:495)[171:com.typesafe.akka.actor:2.4.7]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)[171:com.typesafe.akka.actor:2.4.7]
at akka.dispatch.Mailbox.run(Mailbox.scala:224)[171:com.typesafe.akka.actor:2.4.7]
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)[171:com.typesafe.akka.actor:2.4.7]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
Caused by: java.util.ConcurrentModificationException
at java.util.Vector$Itr.checkForComodification(Vector.java:1184)[:1.8.0_91]
at java.util.Vector$Itr.next(Vector.java:1137)[:1.8.0_91]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:92)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
... 166 more
ERROR 2016-06-27 14:52:34,450 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.StackOverflowError
at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:127) ~[kryo-shaded-3.0.1.jar:?]
at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:667) ~[kryo-shaded-3.0.1.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:778) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
Would it be possible to add a Serializer for the CopiesList
class that's returned by Collections.nCopies()
?
One exists already here but it would be convenient if it was included in this package.
A kryo pool like the one of chill would be useful (e.g. for msm).
In things like EnumMapSerializer, VarInt encoding is smaller than int encoding for both lengths and ordinal() values. Please prefer it.
Serialization trace:
suppressedExceptions (com.package.SomeClass)
at com.esotericsoftware.kryo.serializers.FieldSerializer$ObjectField.read(FieldSerializer.java:626)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:221)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:729)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:134)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:17)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:729)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:134)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:17)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:729)
at org.apache.spark.serializer.KryoDeserializationStream.readObject(KryoSerializer.scala:142)
at org.apache.spark.broadcast.TorrentBroadcast$.unBlockifyObject(TorrentBroadcast.scala:216)
at org.apache.spark.broadcast.TorrentBroadcast$$anonfun$readBroadcastBlock$1.apply(TorrentBroadcast.scala:177)
at org.apache.spark.util.Utils$.tryOrIOException(Utils.scala:1000)
... 18 more
Caused by: java.lang.NullPointerException
at java.util.Collections$UnmodifiableCollection.(Collections.java:1051)
at java.util.Collections$UnmodifiableList.(Collections.java:1204)
at java.util.Collections.unmodifiableList(Collections.java:1190)
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer$UnmodifiableCollection$2.create(UnmodifiableCollectionsSerializer.java:115)
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:72)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:648)
at com.esotericsoftware.kryo.serializers.FieldSerializer$ObjectField.read(FieldSerializer.java:605)
... 30 more
I recently found that UnmodifiableCollectionsSerializer fails to copy values of unmodifiable map, as a workaround I am taking a copy of the values before, well, cloning.. 😱
public static void main(String[] args) {
Map<Integer, Integer> map = Collections.unmodifiableMap(new HashMap<Integer, Integer>() {{
put(1, 1);
}});
KryoPool kryoPool = new KryoPool.Builder(() -> {
Kryo kryo = new Kryo();
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
return kryo;
}).softReferences().build();
kryoPool.run(kryo -> kryo.copy(map.values()));
}
Fails with..
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractCollection.add(AbstractCollection.java:262)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.copy(CollectionSerializer.java:149)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.copy(CollectionSerializer.java:40)
at com.esotericsoftware.kryo.Kryo.copy(Kryo.java:914)
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.copy(UnmodifiableCollectionsSerializer.java:95)
at com.esotericsoftware.kryo.Kryo.copy(Kryo.java:914)
This is a feature request, not a bug.
If I have a nested map like so EnumMap<K1, EnumMap<K2, V>>, how can the EnumMapSerializer be modified to work with it?
At present, it doesn't quite work since the value of the top-level map is (de)serialized as an object instead of as another EnumMap.
In a current project we updated from kryo 1.04 to 2.16. I found some of the serializers pretty useful, but they are still targeting some early version of kryo 2. So I started to adapt this project to the latest version.
In my kryo2 branch I fixed most of the issues resulting from this update. The serializers should work so far but there are still some test issues with the KryoReflectionFactorySupport that relies on some no more existing methods from Kryo itself and some removed serializers. Probably someone can assess if these constructs are still needed and remove or adapt the remaining tests.
I assume it does not at the moment?
What is there to be done until this can be shipped with 3.0 support?
CGLibProxySerializer only works if proxy object has one callback
look at http://grepcode.com/file/repository.springsource.com/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0/net/sf/cglib/proxy/Enhancer.java?av=f#354
without filter you cann't recreate proxy object
IdentifiableChronology.valueOfId()
only appears to use ISOChronology
as a fallback when the provided id is null
. In my case, however, the id as returned by input.readString()
in readChronology()
is "org.joda.time.chrono.ISOChronology".
This obviously matches none of the "COPTIC", "ETHIOPIC" etc. identifiers. Therefore, ISOChronology
is not identified and a "No chronology found for id" exception gets thrown.
I'm not using Kryo or kryo-serializers directly, but registering JodaLocalDateTimeSerializer
with a framework (Apache Flink, as suggested on Stack Overflow), so I'm not in control of any parameters. But this behavior definitely looks strange to me.
Kryo now provides serializers for e.g. Collections singletonList/Map, emptyList/Map, EnumSet etc., so several kryo-serializers are not needed any more. They should be removed / be deprecated.
kryo-serializers-0.37:
java.lang.NullPointerException: null
at reflectasm.java.lang.NullPointerExceptionConstructorAccess.newInstance(Unknown Source)
at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy$1.newInstance(Kryo.java:1237)
at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1090)
at com.esotericsoftware.kryo.serializers.FieldSerializer.create(FieldSerializer.java:570)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:546)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:790)
at com.alibaba.dubbo.common.serialize.support.kryo.KryoObjectInput.readObject(KryoObjectInput.java:125)
at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:94)
at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:117)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.decodeBody(DubboCodec.java:98)
at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:134)
at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:95)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.decode(DubboCountCodec.java:46)
at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalDecoder.messageReceived(NettyCodecAdapter.java:134)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
I am using a library that requires kryo-serializers as a dependency, called PaperDb. The library doesn't use any protobuf, but because of this dependency it adds almost ~7k methods because of it. In Android, method count is highly important because it affects app startup time, and some limitations around 65k methods before some VM hackery is required.
Sadly, the dependency cannot be transitively removed by maven/gradle either. I'd like to ask that a separate module is created containing just the protobuf code and dependency, if possible.
Automatically generating a custom serializer for an @AutoValue
class would be awesome!
See : https://bugzilla.redhat.com/show_bug.cgi?id=1016294#c3 for details.
You have a file which states a proprietary license.
Kryo just released 2.x versions. Any plan to support it?
com.esotericsoftware.kryo.KryoException: Unable to find class: ameba.http.session.SessionStore�����java.lang.String
at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:156) ~[kryo-3.0.1.jar:na]
at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:133) ~[kryo-3.0.1.jar:na]
at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:667) ~[kryo-3.0.1.jar:na]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:778) ~[kryo-3.0.1.jar:na]
at ameba.cache.util.KryoSerializer$3.execute(KryoSerializer.java:87) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:61) ~[kryo-3.0.1.jar:na]
at ameba.cache.util.KryoSerializer.asObject(KryoSerializer.java:82) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
at ameba.cache.util.Serializations.asObject(Serializations.java:32) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
at ameba.cache.util.Serializations.asObject(Serializations.java:38) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
at ameba.cache.Cache.get(Cache.java:365) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
at ameba.http.session.CacheSession.refresh(CacheSession.java:113) ~[ameba-session-0.1.7-20150612.180847-61.jar:na]
at ameba.http.session.CacheSession.isInvalid(CacheSession.java:74) ~[ameba-session-0.1.7-20150612.180847-61.jar:na]
at ameba.http.session.SessionFilter.filter(SessionFilter.java:68) ~[ameba-session-0.1.7-20150612.180847-61.jar:na]
at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:132) ~[jersey-server-2.18.jar:na]
at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:68) ~[jersey-server-2.18.jar:na]
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) ~[jersey-common-2.18.jar:na]
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:300) ~[jersey-server-2.18.jar:na]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.18.jar:na]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common-2.18.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.18.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.18.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.18.jar:na]
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.18.jar:na]
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291) [jersey-server-2.18.jar:na]
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140) [jersey-server-2.18.jar:na]
at ameba.container.grizzly.server.http.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:150) [ameba-container-grizzly-0.1.7-20150528.081010-13.jar:na]
at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:224) [grizzly-http-server-2.3.20.jar:2.3.20]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) [grizzly-framework-2.3.20.jar:2.3.20]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) [grizzly-framework-2.3.20.jar:2.3.20]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
Caused by: java.lang.ClassNotFoundException: ameba.http.session.SessionStore�����java.lang.String
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_80]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_80]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_80]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_80]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[na:1.7.0_80]
at ameba.dev.classloading.ReloadClassLoader.loadClass(ReloadClassLoader.java:158) ~[ameba-dev-0.1.7-20150611.090831-67.jar:0.1.7-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[na:1.7.0_80]
at java.lang.Class.forName0(Native Method) ~[na:1.7.0_80]
at java.lang.Class.forName(Class.java:278) ~[na:1.7.0_80]
at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:154) ~[kryo-3.0.1.jar:na]
... 29 common frames omitted
version : 3.0.1
source code https://github.com/icode/ameba-cache/blob/master/core/src/main/java/ameba/cache/util/KryoSerializer.java
I am not able to install Eclipse plugin that contains kryo-serializers due to not finding the correct version of kryo, even when the kryo 4.0.0 dependency is available.
Missing requirement: kryo serializers 0.41.0 (de.javakaffee.kryo-serializers 0.41.0) requires 'package com.esotericsoftware.kryo [3.0.3,4.0.0)' but it could not be found
As I started to look in the pom.xml I found this:
`
<Import-Package><![CDATA[
com.esotericsoftware.kryo*;version="[3.0.3,4.0)",
esotericsoftware.minlog*;version="[1.2,2.0)",
reflect;resolution:=optional,*]]>
</Import-Package>
Shouldn't it be [3.0.3, 4.0] or [3.0.3, 5.0)?
Am I correct in thinking that these are not implemented?
I'm not an expert in Java or Joda-Time, but my understanding is that at least LocalDate can be useful, even in a distributed system that spans time zones. It can be used to specify a date, for example Christmas 2015 = 25 Dec. 2015, that is independent of time zone.
LocalDateTime is perhaps not so useful for serialization/deserialization screnarios, but maybe for cloning of objects that use it?
Most of the serializers don't provide copy, this should be fixed.
See also http://code.google.com/p/kryo/issues/detail?id=134 and http://code.google.com/p/kryo/issues/detail?id=135
In Java 7, Collections.emptySortedSet() deserialization fails.
It would be nice to add its serializer once this project hits Java 7:
class CollectionsEmptySortedSetSerializer extends Serializer<SortedSet<?>> {
@Override
public void write(Kryo kryo, Output output, SortedSet<?> object) {
}
@Override
public SortedSet<?> read(Kryo kryo, Input input, Class<SortedSet<?>> type) {
return Collections.emptySortedSet();
}
}
Although com.esotericsoftware.kryo dependency is provided inside pom.xml dependencies block with version 4.0.0, you are not including it in generated MANIFEST.MF file due to com.esotericsoftware.kryo*;version="[3.0.3,4.0)"
I created a PR #82
public class SerializableSerializer<T> extends Serializer<T> {
private static final Log LOG = LogFactory.getLog(KryoSerializableSerializer.class);
@Override
public void write(Kryo kryo, Output output, T object) {
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(buf);
out.writeObject(object);
out.close();
output.writeInt(buf.size());
buf.writeTo(output);
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
@Override
public T read(Kryo kryo, Input input, Class<T> type) {
LOG.info("Reading an instance of " + type);
try {
int length = input.readInt();
byte[] data = input.readBytes(length);
ByteArrayInputStream buf = new ByteArrayInputStream(data);
ObjectInputStream in = new ObjectInputStream(buf);
return type.cast(in.readObject());
} catch (IOException e) {
throw Throwables.propagate(e);
} catch (ClassNotFoundException e) {
throw Throwables.propagate(e);
}
}
}
In a pinch, this lets you serialize things which couldn't otherwise be serialized. It's dangerous to register this as a default serializer for Serializer.class as that breaks integer, list, etc. But for things like #25, it's ideal.
Some serializers might suffer from the issue described in cglib/cglib#93
The ImmutableListSerializer attempts to register ImmutableList$Sublist like this
kryo.register(ImmutableList.of(1,2,3).subList(1, 2).getClass(), serializer);
However length 1 sublists are actually of type SingletonImmutableLists now so this method no longer works.
Using the Shipkit Gradle plugin could be pretty useful. It manages the release process by integrating with CI tools such as Travis CI, automatically compiling changelogs, author lists, and incrementing the patch version.
Using Shipkit requires moving to the Gradle build system. That could be a plus or a minus depending on who you talk to, but I feel in general that it is a plus. I believe all of the current Maven plugins used in this build already have Gradle counterparts.
Additionally, the Spotless Gradle plugin could be used to enforce a consistent code style. From a cursory review of the test files, I can already see some odd spacing around generic types and around method arguments, as well as some detected redundant statements/logic.
I'm asking first so I don't go to all the trouble of updating and changing things only to find out you'd rather stick with Maven. It's your call, @magro.
Guava 24.1 introduced new implementations of ImmutableSet
, ImmutableMultiset
, ImmutableMap
and ImmutableBiMap
. These new implementations do not get registered with kryo by the guava support classes in kryo-serializer.
e.g. ImmutableMapSerializer
does not register a serializer for com.google.common.collect.JdkBackedImmutableMap
Serializing Guava ImmutableMap instances with kryo.setRegistrationRequired(true)
can lead to Exceptions like this:
java.lang.IllegalArgumentException: Class is not registered: com.google.common.collect.JdkBackedImmutableMap
Note: To register this class use: kryo.register(com.google.common.collect.JdkBackedImmutableMap.class);
at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:503)
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:557)
kryo.register(File.class, new Serializer<File>() {
@Override
public void write(Kryo kryo, Output output, File object) {
output.writeString(object.getPath());
}
@Override
public File read(Kryo kryo, Input input, Class type) {
return new File(input.readString());
}
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.