Package com.netflix.server.context

Examples of com.netflix.server.context.ContextSerializationException


                @SuppressWarnings("rawtypes")
                Class<ContextSerializer> aClass = (Class<ContextSerializer>) Class.forName(serializerClassName);
                serializer = unifySerializerTypes(aClass.newInstance());
                return serializer;
            } catch (InstantiationException e) {
                throw new ContextSerializationException("Can not instantiate the serializer for class:" + serializerClassName, e);
            } catch (IllegalAccessException e) {
                throw new ContextSerializationException("Can not instantiate the serializer for class:" + serializerClassName, e);
            } catch (ClassNotFoundException e) {
                throw new ContextSerializationException("Can not instantiate the serializer for class:" + serializerClassName, e);
            } catch (ClassCastException e) {
                throw new ContextSerializationException("Serializer:" + serializerClassName + " is not of the required type.", e);
            }
        }

        throw new ContextSerializationException("No serializer found.");
    }
View Full Code Here


        }

        T deserialized = directionAwareContextSerializer.deserialize(contextHolder.getSerialized(), direction,
                                                                     contextHolder.getSerializedVersion());
        if (null == deserialized) {
            throw new ContextSerializationException("Deserializer for context name: " + contextHolder.getContextName() + " returned null.");
        }
        contextHolder.update(deserialized); // caching the deserialized form

        return deserialized;
    }
View Full Code Here

    private static <T> void unwrapSerializationMetadata(ContextHolder<T> holder) throws ContextSerializationException {
        String rawSerializedForm = holder.getRawSerializedForm();
        String[] properties = CONTEXT_SERIALIZATION_PROPS_SEPARATOR_PATTERN.split(rawSerializedForm);
        if(properties.length < CONTEXT_SERIALIZATION_PROPS_COUNT) {
            throw new ContextSerializationException(
                    "Invalid serialized context key format. Number of properties in the serialized form: "
                    + properties.length + " is less than expected: " + CONTEXT_SERIALIZATION_PROPS_COUNT);
        }

        String data = properties[CONTEXT_SERIALIZATION_PROPS_DATA_INDEX];

        if (properties.length > CONTEXT_SERIALIZATION_PROPS_COUNT) {
            // Serialized data has the separator, so we should concat them again
            StringBuilder dataBuilder = new StringBuilder();
            for (int i = CONTEXT_SERIALIZATION_PROPS_DATA_INDEX; i < properties.length; i++) {
                String fragment = properties[i];
                if (dataBuilder.length() > 0) {
                    dataBuilder.append(CONTEXT_SERIALIZATION_PROPS_SEPARATOR);
                }
                dataBuilder.append(fragment);
            }
            data = dataBuilder.toString();
        } else {
            data = unmaskIfEmpty(data);
        }

        int version;
        try {
            version = Integer.parseInt(properties[CONTEXT_SERIALIZATION_PROPS_VERSION_INDEX]);
        } catch (NumberFormatException e) {
            throw new ContextSerializationException(
                    "Illegal serialization version: " + properties[CONTEXT_SERIALIZATION_PROPS_VERSION_INDEX], e);
        }
        holder.update(data, version, properties[CONTEXT_SERIALIZATION_PROPS_SERIALIZER_INDEX]);
    }
View Full Code Here

        String data = contextHolder.hasSerialized()
                      ? contextHolder.getSerialized()
                      : serializer.serialize(contextHolder.getContext(), direction);

        if (null == data) {
            throw new ContextSerializationException("Serializer returned null for context name: " + contextHolder.getContextName());
        }

        if (data.isEmpty()) {
            data = maskEmptyString();
        }
View Full Code Here

TOP

Related Classes of com.netflix.server.context.ContextSerializationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.