protected static void safeWriteResponse(
     final Channel channel, final ManagementProtocolHeader header, final Exception error) {
   if (header.getType() == ManagementProtocol.TYPE_REQUEST) {
     try {
       writeResponse(channel, (ManagementRequestHeader) header, error);
     } catch (IOException ioe) {
       ioe.printStackTrace();
     }
   }
 }
 @Override
 public void handleMessage(
     final Channel channel, final DataInput input, final ManagementProtocolHeader header)
     throws IOException {
   final byte type = header.getType();
   if (type == ManagementProtocol.TYPE_REQUEST) {
     final ManagementRequestHeader request = (ManagementRequestHeader) header;
     handleMessage(channel, input, request);
   } else {
     safeWriteResponse(channel, header, MESSAGES.unrecognizedType(type));
     channel.close();
   }
 }