DATACASS-718 - Fix Integer Overflow in Update.toString().
Original pull request: #169.
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user