Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VersionedRecordExtension throws NumberFormatException for Long numbers #5715

Open
1 task
tcerda95 opened this issue Nov 20, 2024 · 0 comments
Open
1 task
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@tcerda95
Copy link

tcerda95 commented Nov 20, 2024

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

Additional Information/Context

No response

AWS Java SDK version used

2.29.17

JDK version used

21.0.4

Operating System and version

MacOs

@tcerda95 tcerda95 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant