File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
driver-core/src/main/java/com/datastax/driver/core Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,10 @@ IdAndValues getIdAndValues() {
104104 *
105105 * @param statement the new statement to add.
106106 * @return this batch statement.
107+ *
108+ * @throws IllegalStateException if adding the new statement means that this
109+ * {@code BatchStatement} has more than 65536 statements (since this is the maximum number
110+ * of statements for a BatchStatement allowed by the underlying protocol).
107111 */
108112 public BatchStatement add (Statement statement ) {
109113
@@ -115,6 +119,8 @@ public BatchStatement add(Statement statement) {
115119 add (subStatements );
116120 }
117121 } else {
122+ if (statements .size () >= 0xFFFF )
123+ throw new IllegalStateException ("Batch statement cannot contain more than " + 0xFFFF + " statements." );
118124 statements .add (statement );
119125 }
120126 return this ;
Original file line number Diff line number Diff line change @@ -256,6 +256,7 @@ public static class Batch extends Message.Request {
256256 public static final Message .Coder <Batch > coder = new Message .Coder <Batch >() {
257257 public void encode (Batch msg , ChannelBuffer dest ) {
258258 int queries = msg .queryOrIdList .size ();
259+ assert queries <= 0xFFFF ;
259260
260261 dest .writeByte (fromType (msg .type ));
261262 dest .writeShort (queries );
You can’t perform that action at this time.
0 commit comments