Elffuss BraidHub

kikocis/java-driver public

Check maximum number of values passed to SimpleStatement (JAVA-515).
Changeset6124b21eb26d88ad8c665151e522671ba0b08865dc3917a8895ec7b420b5fb9a
Authorolim7t <omichallat+github@gmail.com> · 2014-11-04 14:31 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-11-04 14:42 +01:00
Parents4bcb1e4dc585

Browse the files at this changeset

3 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -4,6 +4,7 @@
44 2.0.8:
55 ------
66 - [bug] Fix token awareness for case-sensitive keyspaces and tables (JAVA-526)
7+- [bug] Check maximum number of values passed to SimpleStatement (JAVA-515)
78
89
910 2.0.7:
modified driver-core/src/main/java/com/datastax/driver/core/SimpleStatement.java +2 −0
@@ -83,6 +83,8 @@
8383 * by {@link DataType#asJavaClass}.
8484 */
8585 public SimpleStatement(String query, Object... values) {
86+ if (values.length > 65535)
87+ throw new IllegalArgumentException("Too many values, the maximum allowed is 65535");
8688 this.query = query;
8789 this.values = convert(values);
8890 }
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