Top Description Fields Constructors Methods
io.netty.handler.codec.serialization

public Class ObjectDecoder

extends LengthFieldBasedFrameDecoder
Class Inheritance
Annotations
@Deprecated
Imports
io.netty.buffer.ByteBuf, .ByteBufInputStream, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.LengthFieldBasedFrameDecoder, java.io.ObjectInputStream, .ObjectOutputStream, .StreamCorruptedException

Deprecated

This class has been deprecated with no replacement, because serialization can be a security liability

A decoder which deserializes the received ByteBufs into Java objects.

Please note that the serialized form this decoder expects is not compatible with the standard ObjectOutputStream. Please use ObjectEncoder or ObjectEncoderOutputStream to ensure the interoperability with this decoder.

Security: serialization can be a security liability, and should not be used without defining a list of classes that are allowed to be desirialized. Such a list can be specified with the jdk.serialFilter system property, for instance. See the serialization filtering article for more information.

Field Summary

Modifier and TypeField and Description
private final ClassResolver
classResolver

Deprecated as a consequence of ClassResolver being deprecated.

Constructor Summary

AccessConstructor and Description
public
ObjectDecoder(ClassResolver
the ClassResolver to use for this decoder
classResolver
)

Deprecated as a consequence of ClassResolver being deprecated.
Creates a new decoder whose maximum object size is 1048576 bytes.
public
ObjectDecoder(int
the maximum byte length of the serialized object. if the length of the received object is greater than this value, StreamCorruptedException will be raised.
maxObjectSize
,
ClassResolver
the ClassResolver which will load the class of the serialized object
classResolver
)

Deprecated as a consequence of ClassResolver being deprecated.
Creates a new decoder with the specified maximum object size.

Method Summary

Modifier and TypeMethod and Description
protected Object
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
)

Overrides io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode.

Create a frame out of the ByteBuf and return it.
Inherited from io.netty.handler.codec.LengthFieldBasedFrameDecoder:
decodeextractFramegetUnadjustedFrameLength

Field Detail

classResolverback to summary
private final ClassResolver classResolver

Deprecated

as a consequence of ClassResolver being deprecated. See corresponding docs for further information.

Constructor Detail

ObjectDecoderback to summary
public ObjectDecoder(ClassResolver classResolver)

Deprecated

as a consequence of ClassResolver being deprecated. See corresponding docs for further information.

Creates a new decoder whose maximum object size is 1048576 bytes. If the size of the received object is greater than 1048576 bytes, a StreamCorruptedException will be raised.

Parameters
classResolver:ClassResolver

the ClassResolver to use for this decoder

ObjectDecoderback to summary
public ObjectDecoder(int maxObjectSize, ClassResolver classResolver)

Deprecated

as a consequence of ClassResolver being deprecated. See corresponding docs for further information.

Creates a new decoder with the specified maximum object size.

Parameters
maxObjectSize:int

the maximum byte length of the serialized object. if the length of the received object is greater than this value, StreamCorruptedException will be raised.

classResolver:ClassResolver

the ClassResolver which will load the class of the serialized object

Method Detail

decodeback to summary
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception

Overrides io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode.

Doc from io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode.

Create a frame out of the ByteBuf and return it.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

Returns:Object

frame the ByteBuf which represent the frame or null if no frame could be created.

Annotations
@Override