@Override public Object read(Kryo kryo, Input input, Class c) { int len = input.readInt(); byte[] ser = new byte[len]; input.readBytes(ser); ByteArrayInputStream bis = new ByteArrayInputStream(ser); try { ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(kryo.getClassLoader(), bis); return ois.readObject(); } catch (Exception e) { throw new RuntimeException(e); } } }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public T read(Kryo kryo, Input input, Class aClass) { try { ObjectMap graphContext = kryo.getGraphContext(); ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this); if (objectStream == null) { // make sure we use Kryo's classloader objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader()); graphContext.put(this, objectStream); } return (T) objectStream.readObject(); } catch (Exception ex) { throw new KryoException("Error during Java deserialization.", ex); } }
Class serializerClass = Class.forName(payloadSerializerName, true, k.getClassLoader()); Serializer serializer = resolveSerializerInstance(k, ListDelegate.class, serializerClass, conf); k.register(ListDelegate.class, serializer); String serializerClassName = registrations.get(klassName); try { Class klass = Class.forName(klassName, true, k.getClassLoader()); serializerClass = Class.forName(serializerClassName, true, k.getClassLoader()); if (serializerClass == null) { k.register(klass); for (String klassName : (List<String>) conf.get(Config.TOPOLOGY_KRYO_DECORATORS)) { try { Class klass = Class.forName(klassName, true, k.getClassLoader()); IKryoDecorator decorator = (IKryoDecorator) klass.newInstance(); decorator.decorate(k);
ObjectInputStreamWithKryoClassLoader(InputStream in, Kryo kryo) throws IOException { super(in); this.loader = kryo.getClassLoader(); }
ObjectInputStreamWithKryoClassLoader(InputStream in, Kryo kryo) throws IOException { super(in); this.loader = kryo.getClassLoader(); }
ObjectInputStreamWithKryoClassLoader(InputStream in, Kryo kryo) throws IOException { super(in); this.loader = kryo.getClassLoader(); }
@Override public Object copy(final Kryo kryo, final Object original) { return Proxy.newProxyInstance( kryo.getClassLoader(), original.getClass().getInterfaces(), Proxy.getInvocationHandler(original) ); } }
@Override public Object copy(final Kryo kryo, final Object original) { return Proxy.newProxyInstance( kryo.getClassLoader(), original.getClass().getInterfaces(), Proxy.getInvocationHandler(original) ); } }
@Override public Object read(final Kryo kryo, final Input input, final Class<? extends Object> type) { final InvocationHandler invocationHandler = (InvocationHandler) kryo.readClassAndObject( input ); final Class<?>[] interfaces = kryo.readObject( input, Class[].class ); final ClassLoader classLoader = kryo.getClassLoader(); try { return Proxy.newProxyInstance( classLoader, interfaces, invocationHandler ); } catch( final RuntimeException e ) { System.err.println( getClass().getName()+ ".read:\n" + "Could not create proxy using classLoader " + classLoader + "," + " have invocationhandler.classloader: " + invocationHandler.getClass().getClassLoader() + " have contextclassloader: " + Thread.currentThread().getContextClassLoader() ); throw e; } }
@Override public Object read(final Kryo kryo, final Input input, final Class<? extends Object> type) { final InvocationHandler invocationHandler = (InvocationHandler) kryo.readClassAndObject( input ); final Class<?>[] interfaces = kryo.readObject( input, Class[].class ); final ClassLoader classLoader = kryo.getClassLoader(); try { return Proxy.newProxyInstance( classLoader, interfaces, invocationHandler ); } catch( final RuntimeException e ) { System.err.println( getClass().getName()+ ".read:\n" + "Could not create proxy using classLoader " + classLoader + "," + " have invocationhandler.classloader: " + invocationHandler.getClass().getClassLoader() + " have contextclassloader: " + Thread.currentThread().getContextClassLoader() ); throw e; } }
@Override @SuppressWarnings("unchecked") public T read(Kryo kryo, Input input, Class<T> type) { try { synchronized (lock) { if (instance == null) { final Method method = kryo.getClassLoader().loadClass(type.getName()).getMethod(methodName); if (!Modifier.isStatic(method.getModifiers())) { throw new KryoException( "Method " + type.getName() + "#" + methodName + " is not static."); } instance = (T) method.invoke(null); } return instance; } } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { throw new KryoException(e); } } }
@Override public Object read(Kryo kryo, Input input, Class type) { try { return new ObjectInputStreamWithClassLoader(input, kryo.getClassLoader()).readObject(); } catch (Exception e) { throw new KryoException("Error during Java deserialization.", e); } }
@SuppressWarnings("unchecked") public Object read (Kryo kryo, Input input, Class type) { try { // ~ InputStream is not closed on purpose because // that would also cause a closing of the underling Kryo input return new ObjectInputStreamWithClassLoader(input, kryo.getClassLoader()).readObject(); } catch (Exception e) { throw new KryoException("Error during Java deserialization.", e); } }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public T read(Kryo kryo, Input input, Class aClass) { try { ObjectMap graphContext = kryo.getGraphContext(); ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this); if (objectStream == null) { // make sure we use Kryo's classloader objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader()); graphContext.put(this, objectStream); } return (T) objectStream.readObject(); } catch (Exception ex) { throw new KryoException("Error during Java deserialization.", ex); } }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public T read(Kryo kryo, Input input, Class aClass) { try { ObjectMap graphContext = kryo.getGraphContext(); ObjectInputStream objectStream = (ObjectInputStream)graphContext.get(this); if (objectStream == null) { // make sure we use Kryo's classloader objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader()); graphContext.put(this, objectStream); } return (T) objectStream.readObject(); } catch (Exception ex) { throw new KryoException("Error during Java deserialization.", ex); } }
protected Registration readName(final Input input) { final int nameId = input.readVarInt(true); if (nameIdToClass == null) nameIdToClass = new IntMap<>(); Class type = nameIdToClass.get(nameId); if (type == null) { // Only read the class name the first time encountered in object graph. final String className = input.readString(); type = getTypeByName(className); if (type == null) { try { type = Class.forName(className, false, kryo.getClassLoader()); } catch (ClassNotFoundException ex) { throw new KryoException("Unable to find class: " + className, ex); } if (nameToClass == null) nameToClass = new ObjectMap<>(); nameToClass.put(className, type); } nameIdToClass.put(nameId, type); } return kryo.getRegistration(type); }
protected Registration readName (Input input) { int nameId = input.readVarInt(true); if (nameIdToClass == null) nameIdToClass = new IntMap(); Class type = nameIdToClass.get(nameId); if (type == null) { // Only read the class name the first time encountered in object graph. String className = input.readString(); type = getTypeByName(className); if (type == null) { try { type = Class.forName(className, false, kryo.getClassLoader()); } catch (ClassNotFoundException ex) { if (WARN) warn("kryo", "Unable to load class " + className + " with kryo's ClassLoader. Retrying with current.."); try { type = Class.forName(className); } catch (ClassNotFoundException e) { throw new KryoException("Unable to find class: " + className, ex); } } if (nameToClass == null) nameToClass = new ObjectMap(); nameToClass.put(className, type); } nameIdToClass.put(nameId, type); if (TRACE) trace("kryo", "Read class name: " + className); } else { if (TRACE) trace("kryo", "Read class name reference " + nameId + ": " + className(type)); } return kryo.getRegistration(type); }
protected Registration readName (Input input) { int nameId = input.readVarInt(true); if (nameIdToClass == null) nameIdToClass = new IntMap(); Class type = nameIdToClass.get(nameId); if (type == null) { // Only read the class name the first time encountered in object graph. String className = input.readString(); type = getTypeByName(className); if (type == null) { try { type = Class.forName(className, false, kryo.getClassLoader()); } catch (ClassNotFoundException ex) { if (WARN) warn("kryo", "Unable to load class " + className + " with kryo's ClassLoader. Retrying with current.."); try { type = Class.forName(className); } catch (ClassNotFoundException e) { throw new KryoException("Unable to find class: " + className, ex); } } if (nameToClass == null) nameToClass = new ObjectMap(); nameToClass.put(className, type); } nameIdToClass.put(nameId, type); if (TRACE) trace("kryo", "Read class name: " + className); } else { if (TRACE) trace("kryo", "Read class name reference " + nameId + ": " + className(type)); } return kryo.getRegistration(type); }
protected Registration readName (Input input) { int nameId = input.readVarInt(true); if (nameIdToClass == null) nameIdToClass = new IntMap(); Class type = nameIdToClass.get(nameId); if (type == null) { // Only read the class name the first time encountered in object graph. String className = input.readString(); type = getTypeByName(className); if (type == null) { try { type = Class.forName(className, false, kryo.getClassLoader()); } catch (ClassNotFoundException ex) { throw new KryoException("Unable to find class: " + className, ex); } if (nameToClass == null) nameToClass = new ObjectMap(); nameToClass.put(className, type); } nameIdToClass.put(nameId, type); if (TRACE) trace("kryo", "Read class name: " + className); } else { if (TRACE) trace("kryo", "Read class name reference " + nameId + ": " + className(type)); } return kryo.getRegistration(type); }
protected Registration readName (Input input) { int nameId = input.readVarInt(true); if (nameIdToClass == null) nameIdToClass = new IntMap(); Class type = nameIdToClass.get(nameId); if (type == null) { // Only read the class name the first time encountered in object graph. String className = input.readString(); if (nameToClass != null) type = nameToClass.get(className); if (type == null) { try { type = Class.forName(className, false, kryo.getClassLoader()); } catch (ClassNotFoundException ex) { throw new KryoException("Unable to find class: " + className, ex); } if (nameToClass == null) nameToClass = new ObjectMap(); nameToClass.put(className, type); } nameIdToClass.put(nameId, type); if (TRACE) trace("kryo", "Read class name: " + className); } else { if (TRACE) trace("kryo", "Read class name reference " + nameId + ": " + className(type)); } return kryo.getRegistration(type); }