-
Notifications
You must be signed in to change notification settings - Fork 976
Description
Describe the bug
VersionedRecordExtension uses Interger.parseInt to convert the attribute annotated with DynamoDbVersionAttribute from a String to a Integer.
This is wrong because you can annotate Longs with DynamoDbVersionAttribute. When such Long has a value that cannot be represented with an Integer, VersionedRecordExtension throws NumberFormatException.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
VersionedRecordExtension should not throw NumberFormatException for numbers that cannot be represent by an Integer such as 134117278857279131.
Current Behavior
When a Long attribute has a non-Integer representable value such as 134117278857279131L and is annotated with @DynamoDbVersionAttribute, then VersionedRecordExtension throws NumberFormatException
Reproduction Steps
@DynamoDbBean
public class Customer {
private String id;
private String name;
private Long version;
@DynamoDbPartitionKey
public String getId() { return this.id; }
public void setId(String id) { this.id = id; }
public String getName() { return this.name; }
public void setName(String name) { this.name = name; }
@DynamoDbVersionAttribute
public Long getVersion() { return this.version; }
public void setVersion(Long version) { this.version = version; }
}
Customer customer = new Customer();
customer.setId("1");
customer.setName("CustomerName");
customer.setVersion(134117278857279131L);
// Throws NumberFormatException
customerTable.putItem(customer)
Possible Solution
Use Long.parseLong instead of Integer.parseInt in
Line 126 in 9530396
| int existingVersion = Integer.parseInt(existingVersionValue.get().n()); |
Additional Information/Context
No response
AWS Java SDK version used
2.29.17
JDK version used
21.0.4
Operating System and version
MacOs