From 3a1b01dd431d3e0ddbfe0874c992182a4a070c8c Mon Sep 17 00:00:00 2001 From: Kirill Vlasov Date: Thu, 10 Dec 2015 14:32:07 +0500 Subject: [PATCH] Fixing squid:S1168 - Empty arrays and collections should be returned instead of null --- .travis.yml | 5 ++++- .../common/cron/CronExpression.java | 17 +++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5177eeff..f2f11926 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/src/main/java/org/xbib/elasticsearch/common/cron/CronExpression.java b/src/main/java/org/xbib/elasticsearch/common/cron/CronExpression.java index fd866327..be38efb6 100644 --- a/src/main/java/org/xbib/elasticsearch/common/cron/CronExpression.java +++ b/src/main/java/org/xbib/elasticsearch/common/cron/CronExpression.java @@ -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 { @@ -289,8 +290,8 @@ protected void buildExpression(String expression) { if (exprOn <= YEAR) { storeExpressionVals(0, "*", YEAR); } - TreeSet dow = getSet(DAY_OF_WEEK); - TreeSet dom = getSet(DAY_OF_MONTH); + Set dow = getSet(DAY_OF_WEEK); + Set dom = getSet(DAY_OF_MONTH); boolean dayOfMSpec = !dom.contains(NO_SPEC); boolean dayOfWSpec = !dow.contains(NO_SPEC); if (!dayOfMSpec || dayOfWSpec) { @@ -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 set = getSet(type); + Set set = getSet(type); set.add(val); i++; return i; @@ -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 set = getSet(type); + Set set = getSet(type); set.add(val); i++; return i; @@ -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 set = getSet(type); + Set set = getSet(type); set.add(val); i++; return i; @@ -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 set = getSet(type); + Set set = getSet(type); if (type == SECOND || type == MINUTE) { if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) { throw new ParseException( @@ -836,7 +837,7 @@ protected void addToSet(int val, int end, int incr, int type) } } - private TreeSet getSet(int type) { + private Set getSet(int type) { switch (type) { case SECOND: return seconds; @@ -853,7 +854,7 @@ private TreeSet getSet(int type) { case YEAR: return years; default: - return null; + return Collections.emptySet(); } }