// failcheck
if (filter == null) { buf.resetReaderIndex(); return; }
// try create the message
Message message;
try
{
message = messageClazz.newInstance();
}
catch (InstantiationException | IllegalAccessException ex)
{
LOGGER.error("Could not create an instance of an message.", ex);
buf.resetReaderIndex();
return;
}
// dont forget to initialize the message
message.init(ctx.channel());
// try serialize the message
if (!filter.deserialize(buf, message))
{
buf.resetReaderIndex();
return;
}
// finally add the message
result.add(message);
LOGGER.debug("Got: {}", message.toString());
}
}