You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
@tcerda95 I see the issue, thank you for the report.
The fix will not be the simple one line change, I tested setting the value to 2147483647 (which is the Integer.MAX_VALUE) and the Enhanced Client will not update to 2147483647 + 1, it actually overflows to -2147483648, indicating that Long is not supported. The VersionAttribute write logic would need to change too, if we decide to support Long.
I'll discuss this case with the team, and will update here what we decide.
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
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 throwsNumberFormatException
Reproduction Steps
Possible Solution
Use
Long.parseLong
instead ofInteger.parseInt
inaws-sdk-java-v2/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtension.java
Line 126 in 9530396
Additional Information/Context
No response
AWS Java SDK version used
2.29.17
JDK version used
21.0.4
Operating System and version
MacOs
The text was updated successfully, but these errors were encountered: