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

public Class CompatibleObjectEncoder

extends MessageToByteEncoder<Serializable>
Class Inheritance
Annotations
@Deprecated
Static Imports
io.netty.util.internal.ObjectUtil.checkPositiveOrZero

Deprecated

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

An encoder which serializes a Java object into a ByteBuf (interoperability version).

This encoder is interoperable with the standard Java object streams such as ObjectInputStream and ObjectOutputStream.

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 int
private int

Constructor Summary

AccessConstructor and Description
public
CompatibleObjectEncoder()

Creates a new instance with the reset interval of 16.

public
CompatibleObjectEncoder(int
the number of objects between ObjectOutputStream#reset(). 0 will disable resetting the stream, but the remote peer will be at the risk of getting OutOfMemoryError in the long term.
resetInterval
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
protected void
encode(ChannelHandlerContext ctx, Serializable
the message to encode
msg
,
ByteBuf
the ByteBuf into which the encoded message will be written
out
)

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf.
protected ObjectOutputStream
newObjectOutputStream(OutputStream out)

Creates a new ObjectOutputStream which wraps the specified OutputStream.

Inherited from io.netty.handler.codec.MessageToByteEncoder:
acceptOutboundMessageallocateBufferisPreferDirectwrite

Field Detail

resetIntervalback to summary
private final int resetInterval
writtenObjectsback to summary
private int writtenObjects

Constructor Detail

CompatibleObjectEncoderback to summary
public CompatibleObjectEncoder()

Creates a new instance with the reset interval of 16.

CompatibleObjectEncoderback to summary
public CompatibleObjectEncoder(int resetInterval)

Creates a new instance.

Parameters
resetInterval:int

the number of objects between ObjectOutputStream#reset(). 0 will disable resetting the stream, but the remote peer will be at the risk of getting OutOfMemoryError in the long term.

Method Detail

encodeback to summary
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Doc from io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToByteEncoder belongs to

msg:Serializable

the message to encode

out:ByteBuf

the ByteBuf into which the encoded message will be written

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
newObjectOutputStreamback to summary
protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws Exception

Creates a new ObjectOutputStream which wraps the specified OutputStream. Override this method to use a subclass of the ObjectOutputStream.