DATACASS-718 - Fix Integer Overflow in Update.toString().

Original pull request: #169.
This commit is contained in:
chema
2020-01-16 17:18:00 +01:00
committed by Mark Paluch
parent 94759543f8
commit 315c6b3ce0
2 changed files with 12 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ import org.springframework.util.StringUtils;
* </pre>
*
* @author Mark Paluch
* @author Chema Vinacua
* @since 2.0
*/
public class Update {
@@ -662,7 +663,7 @@ public class Update {
@Override
public String toString() {
return String.format("%s = %s %s %d", getColumnName(), getColumnName(), value.doubleValue() > 0 ? "+" : "-",
Math.abs(value.intValue()));
Math.abs(value.longValue()));
}
}

View File

@@ -24,6 +24,7 @@ import org.springframework.data.cassandra.core.query.Update.IncrOp;
* Unit tests for {@link Update}.
*
* @author Mark Paluch
* @author Chema Vinacua
*/
public class UpdateUnitTests {
@@ -134,4 +135,13 @@ public class UpdateUnitTests {
assertThat(update.getUpdateOperations()).hasSize(1);
assertThat(update.getUpdateOperations().iterator().next()).isInstanceOf(IncrOp.class);
}
@Test // DATACASS-718
public void shouldCreateIncrementLongUpdate() {
Update update = Update.empty().increment("foo", 2400000000l);
assertThat(update.getUpdateOperations()).hasSize(1);
assertThat(update.toString()).isEqualTo("foo = foo + 2400000000");
}
}