UnsignedInteger localHandle = transportLink.getLocalHandle();
transportLink.clearLocalHandle();
transportSession.freeLocalHandle(localHandle);
Detach detach = new Detach();
detach.setHandle(localHandle);
EndpointError localError = link.getLocalError();
if( localError !=null ) {
org.apache.qpid.proton.type.transport.Error error = new org.apache.qpid.proton.type.transport.Error();
error.setCondition(Symbol.getSymbol(localError.getName()));
error.setDescription(localError.getDescription());
detach.setError(error);
}
int frameBytes = writeFrame(buffer, transportSession.getLocalChannel(), detach, null, null);
written += frameBytes;