kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 6124b21eb26d88ad8c665151e522671ba0b08865dc3917a8895ec7b420b5fb9a |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-11-04 14:31 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-11-04 14:42 +01:00 |
| Parents | 4bcb1e4dc585 |
3 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | 2.0.8: |
| 5 | 5 | ------ |
| 6 | 6 | - [bug] Fix token awareness for case-sensitive keyspaces and tables (JAVA-526) |
| 7 | +- [bug] Check maximum number of values passed to SimpleStatement (JAVA-515) | |
| 7 | 8 | |
| 8 | 9 | |
| 9 | 10 | 2.0.7: |
modified driver-core/src/main/java/com/datastax/driver/core/SimpleStatement.java +2 −0
| @@ -83,6 +83,8 @@ | ||
| 83 | 83 | * by {@link DataType#asJavaClass}. |
| 84 | 84 | */ |
| 85 | 85 | public SimpleStatement(String query, Object... values) { |
| 86 | + if (values.length > 65535) | |
| 87 | + throw new IllegalArgumentException("Too many values, the maximum allowed is 65535"); | |
| 86 | 88 | this.query = query; |
| 87 | 89 | this.values = convert(values); |
| 88 | 90 | } |
added driver-core/src/test/java/com/datastax/driver/core/SimpleStatementTest.java +14 −0
| @@ -0,0 +1,14 @@ | ||
| 1 | +package com.datastax.driver.core; | |
| 2 | + | |
| 3 | +import java.util.Collections; | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +import org.testng.annotations.Test; | |
| 7 | + | |
| 8 | +public class SimpleStatementTest { | |
| 9 | + @Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) | |
| 10 | + public void should_fail_if_too_many_variables() { | |
| 11 | + List<Object> args = Collections.nCopies(1 << 16, (Object)1); | |
| 12 | + new SimpleStatement("mock query", args.toArray()); | |
| 13 | + } | |
| 14 | +} | |
| No newline at the end of the file |