Check timeZone() argument in AbstractSqlQueryRequest (#31822)

A value of `null` will throw an IAE.
This commit is contained in:
hanbj 2018-07-06 20:35:03 +08:00 committed by Christoph Büscher
parent 89cb0872cf
commit 03adbf2a39
2 changed files with 7 additions and 1 deletions

View File

@ -112,7 +112,7 @@ public abstract class AbstractSqlQueryRequest extends AbstractSqlRequest impleme
}
public AbstractSqlQueryRequest timeZone(TimeZone timeZone) {
if (query == null) {
if (timeZone == null) {
throw new IllegalArgumentException("time zone may not be null.");
}
this.timeZone = timeZone;

View File

@ -110,4 +110,10 @@ public class SqlQueryRequestTests extends AbstractSerializingTestCase<SqlQueryRe
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());
}
}