Skip to content

AttributeValue is not serializable #3143

@nirtsruya

Description

@nirtsruya

Describe the bug

The AttributeValue class implements the Serializable interface. However, when trying to serialize it using java.io.ObjectOutputStream writeObject method I get the following error:
java.io.NotSerializableException: software.amazon.awssdk.core.util.DefaultSdkAutoConstructList

The reason is that the AttributeValue.Builder the constructor sets DefaultSdkAutoConstructList (which is not serializable) to all list type properties such as "l", "ss", "ns", and "bs"

Expected behavior

AttributeValue should be serializable, and not throw an exception during serialization.

Current behavior

An exception - java.io.NotSerializableException: software.amazon.awssdk.core.util.DefaultSdkAutoConstructList is thrown when trying to serialize it using java.io.ObjectOutputStream writeObject method

Caused by: java.io.NotSerializableException: software.amazon.awssdk.core.util.DefaultSdkAutoConstructList
	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1185)
	at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1553)
	at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1510)
	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1433)
	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1179)
	at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349)

Steps to Reproduce

Simple code:

AttributeValue attributeValue = AttributeValue.builder()
                .n("123")
                .build();

try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream)) {

    objectOutputStream.writeObject(attributeValue);

} catch (IOException e) {
    throw new RuntimeException(e);
}

Possible Solution

software.amazon.awssdk.core.util.DefaultSdkAutoConstructList should implement Serializable

Context

No response

AWS Java SDK version used

2.17.161

JDK version used

11.0.14.1

Operating System and version

Ubuntu 20.04.4 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions