Skip to content

#195 bug fix dont throw null pointer when rows is empty #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collections.emptyList

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable types are the ? in prepared statements, yours has none so can remove the withVariableTypes. This is a stubbed tests so doesn't really matter but the real server would reject this priming request.

.build();
//when
underTest.prime(pr);

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