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

Integer Overflow using Update [DATACASS-718] #885

Closed
spring-projects-issues opened this issue Jan 16, 2020 · 6 comments
Closed

Integer Overflow using Update [DATACASS-718] #885

spring-projects-issues opened this issue Jan 16, 2020 · 6 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jan 16, 2020

Chema Vinacua opened DATACASS-718 and commented

Update increment operation fails when using long numbers.

Long numbers get wrongly casted to integer so negative numbers are applied.

Test Code:
Update update = Update.empty().increment("counter", 2400000000l);
log.info("Update: {}", update);

 

The problem comes from the Update.IncrOp.toString() method which converts the long to int:
public String toString() {
return String.format("%s = %s %s %d", getColumnName(), getColumnName(), value.doubleValue() > 0 ? "+" : "-",
Math.abs(value.intValue()));
}

 


Affects: 2.1.15 (Lovelace SR15), 2.2.4 (Moore SR4)

Issue Links:

  • DATACASS-735 Using long numbers with Update.incr(…) cause integer overflow
    ("is superseded by")

Referenced from: pull request #169

Backported to: 2.2.5 (Moore SR5), 2.1.16 (Lovelace SR16)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 16, 2020

Chema Vinacua commented

I am going to prepare a pull request to fix the issue

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 20, 2020

Chema Vinacua commented

Fixed on pull request: #169

 

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 17, 2020

Mark Paluch commented

Thanks a lot. I changed the priority to trivial as the issue affected only the toString representation and had no impact on the actual update operation

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 26, 2020

Chema Vinacua commented

Thanks Mark.

But be aware that this issue is not only the toString representation. This method is the one used to construct the actual UPDATE

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 26, 2020

Mark Paluch commented

The referenced PR contained only a fix for the toString representation. StatementFactory wasn't touched at all which means the bug still persists:

https://github.com/spring-projects/spring-data-cassandra/blob/2.2.x/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/StatementFactory.java#L544-L546

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 26, 2020

Mark Paluch commented

I created DATACASS-735 to address the remaining issue that persists in versions 2.1 - 3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants