Oh, one issue. Doesn't using the graph context allow me to ignore threading
issues? If someone registers the same instance of this to two different
Kryo instances won't there be a threading issue that is avoided with the
graph context? Or should I not worry about that type of usage and just mark
that it is not thread safe?


On Fri, Jan 10, 2014 at 10:48 AM, Nathan Sweet <notifications@github.com>wrote:

> In src/com/esotericsoftware/kryo/serializers/ExternalizableSerializer.java:
>
> > +            object.readExternal( getObjectInput( kryo, input ) );
> > +            return object;
> > +        }
> > +        catch ( Exception e ) {
> > +            throw new KryoException( e );
> > +        }
> > +    }
> > +
> > +    @SuppressWarnings( "unchecked" )
> > +    private ObjectOutput getObjectOutput( Kryo kryo, Output output ) {
> > +        ObjectMap graphContext = kryo.getGraphContext();
> > +        ObjectOutput objectOutput = (ObjectOutput)graphContext.get( this );
> > +        if (objectOutput == null) {
> > +            objectOutput = new KryoObjectOutput( kryo, output );
> > +            graphContext.put(this, objectOutput);
> > +        }
>
> I don't think you need to use the graph context to avoid allocation. Use a
> single KryoObjectOutput on ExternalizableSerializer, use setKryo and
> setOutput to configure it. It doesn't matter that read() and write() are
> reentrant because for any given object graph serialization it will be the
> same Kryo and Output instances.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/EsotericSoftware/kryo/pull/167/files#r8797886>
> .
>