Skip to content
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

Empty arrays and collections should be returned instead of null #739

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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ language: java
jdk:
- oraclejdk8

script: ./bin/travis/run-tests.sh
before_script:
- echo "MAVEN_OPTS='-Xmx4096m -Xms4096m'" > ~/.mavenrc

script: travis_wait ./bin/travis/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.TreeSet;
import java.util.Collections;

public final class CronExpression implements Cloneable {

Expand Down Expand Up @@ -289,8 +290,8 @@ protected void buildExpression(String expression) {
if (exprOn <= YEAR) {
storeExpressionVals(0, "*", YEAR);
}
TreeSet<Integer> dow = getSet(DAY_OF_WEEK);
TreeSet<Integer> dom = getSet(DAY_OF_MONTH);
Set<Integer> dow = getSet(DAY_OF_WEEK);
Set<Integer> dom = getSet(DAY_OF_MONTH);
boolean dayOfMSpec = !dom.contains(NO_SPEC);
boolean dayOfWSpec = !dow.contains(NO_SPEC);
if (!dayOfMSpec || dayOfWSpec) {
Expand Down Expand Up @@ -497,7 +498,7 @@ protected int checkNext(int pos, String s, int val, int type)
} else {
throw new ParseException("'L' option is not valid here (pos=" + i + ")", i);
}
TreeSet<Integer> set = getSet(type);
Set<Integer> set = getSet(type);
set.add(val);
i++;
return i;
Expand All @@ -512,7 +513,7 @@ protected int checkNext(int pos, String s, int val, int type)
if (val > 31) {
throw new ParseException("'W' option does not make sense with values larger than 31 (max number of days in a month)", i);
}
TreeSet<Integer> set = getSet(type);
Set<Integer> set = getSet(type);
set.add(val);
i++;
return i;
Expand All @@ -530,7 +531,7 @@ protected int checkNext(int pos, String s, int val, int type)
} catch (Exception e) {
throw new ParseException("numeric value between 1 and 5 must follow the '#' option", i);
}
TreeSet<Integer> set = getSet(type);
Set<Integer> set = getSet(type);
set.add(val);
i++;
return i;
Expand Down Expand Up @@ -705,7 +706,7 @@ protected int findNextWhiteSpace(int i, String s) {

protected void addToSet(int val, int end, int incr, int type)
throws ParseException {
TreeSet<Integer> set = getSet(type);
Set<Integer> set = getSet(type);
if (type == SECOND || type == MINUTE) {
if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
throw new ParseException(
Expand Down Expand Up @@ -836,7 +837,7 @@ protected void addToSet(int val, int end, int incr, int type)
}
}

private TreeSet<Integer> getSet(int type) {
private Set<Integer> getSet(int type) {
switch (type) {
case SECOND:
return seconds;
Expand All @@ -853,7 +854,7 @@ private TreeSet<Integer> getSet(int type) {
case YEAR:
return years;
default:
return null;
return Collections.emptySet();
}
}

Expand Down