diff --git a/src/dorkbox/network/connection/ConnectionImpl.java b/src/dorkbox/network/connection/ConnectionImpl.java index 29316633..061540e5 100644 --- a/src/dorkbox/network/connection/ConnectionImpl.java +++ b/src/dorkbox/network/connection/ConnectionImpl.java @@ -1144,9 +1144,22 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements CryptoConne try { kryo = manager.takeKryo(); + + // because the INTERFACE is what is registered with kryo (not the impl) we have to temporarily permit unregistered classes (which have an ID of -1) + // so we can cache the instantiator for this class. + boolean registrationRequired = kryo.isRegistrationRequired(); + + kryo.setRegistrationRequired(false); + // this is what creates a new instance of the impl class, and stores it as an ID. object = kryo.newInstance(implementationClass); + if (registrationRequired) { + // only if it's different should we call this again. + kryo.setRegistrationRequired(true); + } + + rmiId = rmiBridge.register(object); if (rmiId == RmiBridge.INVALID_RMI) {