Package org.jivesoftware.openfire.nio
Class NettyXMPPDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
org.jivesoftware.openfire.nio.NettyXMPPDecoder
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class NettyXMPPDecoder
extends io.netty.handler.codec.ByteToMessageDecoder
A Netty pipeline decoder that parses raw bytes from an XMPP connection into discrete XML stanzas.
This decoder sits in the Netty channel pipeline and delegates to a per-channel
XMLLightweightParser to
incrementally parse incoming data. Fully parsed stanzas are passed to the next handler in the pipeline via the
out list.
As a security measure, connections that attempt to send a single stanza exceeding the configured maximum buffer size
are closed with a policy-violation stream error.-
Nested Class Summary
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDecodes incoming bytes from the channel into one or more XMPP stanzas.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Handles exceptions thrown during decoding or elsewhere in the pipeline.Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
Constructor Details
-
NettyXMPPDecoder
public NettyXMPPDecoder()
-
-
Method Details
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) throws Exception Decodes incoming bytes from the channel into one or more XMPP stanzas. Retrieves theXMLLightweightParserassociated with this channel and feeds it the available bytes. Any fully parsed stanzas are added tooutfor processing by subsequent handlers in the pipeline. If the parser's internal buffer has exceeded the maximum allowed size, the connection is closed immediately with apolicy-violationstream error and no further parsing is attempted.- Specified by:
decodein classio.netty.handler.codec.ByteToMessageDecoder- Parameters:
ctx- the channel handler context, used to retrieve channel attributesin- the incoming byte buffer containing raw XMPP dataout- the list to which fully decoded stanzas are added- Throws:
Exception- if an error occurs during parsing
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception Handles exceptions thrown during decoding or elsewhere in the pipeline. Categorises the cause and closes the connection with an appropriate stream error. Full stack traces are intentionally logged at DEBUG level only, to avoid excessive log noise during production operation where port scanners and misconfigured clients can produce a high volume of these exceptions. If noNettyConnectionhas been associated with the channel yet (e.g. an exception occurs during early channel setup before registration), the exception is logged but no close attempt is made.- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the channel handler contextcause- the exception that was caught- Throws:
Exception- if an error occurs while handling the exception
-