Skip to content

Commit

Permalink
Check timeZone() argument in AbstractSqlQueryRequest (#31822)
Browse files Browse the repository at this point in the history
A value of `null` will throw an IAE.
  • Loading branch information
hanbj authored and Christoph Büscher committed Jul 6, 2018
1 parent 89cb087 commit 03adbf2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public TimeZone timeZone() {
}

public AbstractSqlQueryRequest timeZone(TimeZone timeZone) {
if (query == null) {
if (timeZone == null) {
throw new IllegalArgumentException("time zone may not be null.");
}
this.timeZone = timeZone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ protected SqlQueryRequest mutateInstance(SqlQueryRequest instance) {
mutator.accept(newRequest);
return newRequest;
}

public void testTimeZoneNullException() {
final SqlQueryRequest sqlQueryRequest = createTestInstance();
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> sqlQueryRequest.timeZone(null));
assertEquals("time zone may not be null.", e.getMessage());
}
}

0 comments on commit 03adbf2

Please sign in to comment.