Skip to main content
Version: latest-snapshot

Configure serialization

For data to be sent over a network between cluster members and/or clients, it needs to be serialized into raw bytes. Hazelcast has many serialization options to choose from, depending on what you plan on doing with your data.

With Operator you can configure serialization using the Hazelcast Custom Resource (CR). To understand serialization, see the Serializing objects and clases.

You can find more detailed information in the API reference.

Configure compact serialization​

To configure compact serialization, define the compactSerialization section. The following configuration will register an explicit serializer com.example.FooSerializer along with a zero config serializer for the com.example.Bar class.

Compact serialization example configuration
yaml
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hazelcast
spec:
serialization:
compactSerialization:
serializers:
- com.example.FooSerializer
classes:
- com.example.Bar

Configure custom serialization​

To register custom serializers, define the list of serializers and types in the serializers section. The following configuration will register two custom serializers.

Custom serializers example configuration
yaml
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hazelcast
spec:
serialization:
serializers:
- className: com.example.FooSerializer
typeClass: com.example.Foo
- className: com.example.BarSerializer
typeClass: com.example.Bar

Disallow deserialization of untrusted Java classes​

To stop Hazelcast from deserializing arbitrary classes, you can allow or disallow deserialization of Java classes by class name or package name using the javaSerializationFilter option.

Java serialization filter example configuration
yaml
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hazelcast
spec:
serialization:
javaSerializationFilter:
whitelist:
classes:
- example.Foo
packages:
- com.acme.app
prefixes:
- com.hazelcast.
- java.
- javax.
- \[
blacklist:
classes:
- com.acme.app.BeanComparator