Skip to content

Commit

Permalink
scassandra#195 bug fix dont throw null pointer when rows is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra Batey committed Mar 14, 2018
1 parent bc23971 commit 01f6e84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public Map<String, Object> getConfig() {

public static class ThenBuilder {
private List<CqlType> variable_types;
private List<Map<String, ? extends Object>> rows;
private List<Map<String, ? extends Object>> rows = new ArrayList<>();
private Result result;
private Long fixedDelay;
private Map<String, Object> config = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.scassandra.cql.PrimitiveType.*;
import static org.scassandra.http.client.BatchQueryPrime.batchQueryPrime;
Expand Down Expand Up @@ -921,4 +922,21 @@ public void testRetrievingOfMultiPreparedPrimesFailed() {
//when
underTest.retrieveQueryPrimes();
}

// bug fix https://github.com/scassandra/scassandra-server/issues/195
@Test
public void primeWithEmptyRowsDoesntThrowNullPointer() {
//given
stubFor(post(urlEqualTo(PRIME_PREPARED_PATH)).willReturn(aResponse().withStatus(200)));
PrimingRequest pr = PrimingRequest.preparedStatementBuilder()
.withQuery("select * from people")
.withThen(PrimingRequest.then().withVariableTypes(TEXT))
.build();
//when
underTest.prime(pr);

//then
List<Map<String, ?>> rows = pr.getThen().getRows();
assertTrue(rows.isEmpty());
}
}

0 comments on commit 01f6e84

Please sign in to comment.