@Override
 public IdentifiedDataSerializable create(int typeId) {
   if (typeId >= 0 && typeId < len) {
     ConstructorFunction<Integer, IdentifiedDataSerializable> factory = constructors[typeId];
     return factory != null ? factory.createNew(typeId) : null;
   }
   return null;
 }
 @Override
 public IdentifiedDataSerializable create(int typeId, Version version) {
   if (typeId >= 0 && typeId < len) {
     ConstructorFunction<Integer, IdentifiedDataSerializable> factory = constructors[typeId];
     if (factory == null) {
       return null;
     }
     if (factory instanceof VersionAwareConstructorFunction) {
       return ((VersionAwareConstructorFunction<Integer, IdentifiedDataSerializable>) factory)
           .createNew(typeId, version);
     } else {
       return factory.createNew(typeId);
     }
   }
   return null;
 }
 public void cleanResources(
     ConstructorFunction<Object, Throwable> responseCtor, ClientConnection connection) {
   final Iterator<Map.Entry<Integer, ClientInvocation>> iter = callIdMap.entrySet().iterator();
   while (iter.hasNext()) {
     final Map.Entry<Integer, ClientInvocation> entry = iter.next();
     final ClientInvocation invocation = entry.getValue();
     if (connection.equals(invocation.getSendConnection())) {
       iter.remove();
       invocation.notifyException(responseCtor.createNew(null));
       eventHandlerMap.remove(entry.getKey());
     }
   }
   final Iterator<ClientListenerInvocation> iterator = eventHandlerMap.values().iterator();
   while (iterator.hasNext()) {
     final ClientInvocation invocation = iterator.next();
     if (connection.equals(invocation.getSendConnection())) {
       iterator.remove();
       invocation.notifyException(responseCtor.createNew(null));
     }
   }
 }