-
Notifications
You must be signed in to change notification settings - Fork 977
Description
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