Skip to content

Commit e441f8d

Browse files
Kris20030907RongtongJin
authored andcommitted
[ISSUE #9201] cleanup dead code patterns and improve readability and maintainability
1 parent 822a20d commit e441f8d

1 file changed

Lines changed: 11 additions & 56 deletions

File tree

filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.java

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,14 @@
4141
public class SelectorParser implements SelectorParserConstants {
4242

4343
private static final Cache<String, Object> PARSE_CACHE = CacheBuilder.newBuilder().maximumSize(100).build();
44-
// private static final String CONVERT_STRING_EXPRESSIONS_PREFIX = "convert_string_expressions:";
4544

4645
public static BooleanExpression parse(String sql) throws MQFilterException {
47-
// sql = "("+sql+")";
4846
Object result = PARSE_CACHE.getIfPresent(sql);
4947
if (result instanceof MQFilterException) {
5048
throw (MQFilterException) result;
5149
} else if (result instanceof BooleanExpression) {
5250
return (BooleanExpression) result;
5351
} else {
54-
55-
// boolean convertStringExpressions = false;
56-
// if( sql.startsWith(CONVERT_STRING_EXPRESSIONS_PREFIX)) {
57-
// convertStringExpressions = true;
58-
// sql = sql.substring(CONVERT_STRING_EXPRESSIONS_PREFIX.length());
59-
// }
60-
// if( convertStringExpressions ) {
61-
// ComparisonExpression.CONVERT_STRING_EXPRESSIONS.set(true);
62-
// }
6352
ComparisonExpression.CONVERT_STRING_EXPRESSIONS.set(true);
6453
try {
6554

@@ -71,9 +60,6 @@ public static BooleanExpression parse(String sql) throws MQFilterException {
7160
throw t;
7261
} finally {
7362
ComparisonExpression.CONVERT_STRING_EXPRESSIONS.remove();
74-
// if( convertStringExpressions ) {
75-
// ComparisonExpression.CONVERT_STRING_EXPRESSIONS.remove();
76-
// }
7763
}
7864
}
7965
}
@@ -111,12 +97,8 @@ private BooleanExpression asBooleanExpression(Expression value) throws ParseExce
11197
// Grammar
11298
// ----------------------------------------------------------------------------
11399
final public BooleanExpression JmsSelector() throws ParseException {
114-
Expression left = null;
115-
left = orExpression();
116-
{
117-
if (true) return asBooleanExpression(left);
118-
}
119-
throw new Error("Missing return statement in function");
100+
Expression left = orExpression();
101+
return asBooleanExpression(left);
120102
}
121103

122104
final public Expression orExpression() throws ParseException {
@@ -136,10 +118,7 @@ final public Expression orExpression() throws ParseException {
136118
right = andExpression();
137119
left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
138120
}
139-
{
140-
if (true) return left;
141-
}
142-
throw new Error("Missing return statement in function");
121+
return left;
143122
}
144123

145124
final public Expression andExpression() throws ParseException {
@@ -159,10 +138,7 @@ final public Expression andExpression() throws ParseException {
159138
right = equalityExpression();
160139
left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));
161140
}
162-
{
163-
if (true) return left;
164-
}
165-
throw new Error("Missing return statement in function");
141+
return left;
166142
}
167143

168144
final public Expression equalityExpression() throws ParseException {
@@ -213,10 +189,7 @@ final public Expression equalityExpression() throws ParseException {
213189
}
214190
}
215191
}
216-
{
217-
if (true) return left;
218-
}
219-
throw new Error("Missing return statement in function");
192+
return left;
220193
}
221194

222195
final public Expression comparisonExpression() throws ParseException {
@@ -387,10 +360,7 @@ final public Expression comparisonExpression() throws ParseException {
387360
}
388361
}
389362
}
390-
{
391-
if (true) return left;
392-
}
393-
throw new Error("Missing return statement in function");
363+
return left;
394364
}
395365

396366
final public Expression unaryExpr() throws ParseException {
@@ -427,10 +397,7 @@ final public Expression unaryExpr() throws ParseException {
427397
throw new ParseException();
428398
}
429399
}
430-
{
431-
if (true) return left;
432-
}
433-
throw new Error("Missing return statement in function");
400+
return left;
434401
}
435402

436403
final public Expression primaryExpr() throws ParseException {
@@ -457,10 +424,7 @@ final public Expression primaryExpr() throws ParseException {
457424
jj_consume_token(-1);
458425
throw new ParseException();
459426
}
460-
{
461-
if (true) return left;
462-
}
463-
throw new Error("Missing return statement in function");
427+
return left;
464428
}
465429

466430
final public ConstantExpression literal() throws ParseException {
@@ -497,10 +461,7 @@ final public ConstantExpression literal() throws ParseException {
497461
jj_consume_token(-1);
498462
throw new ParseException();
499463
}
500-
{
501-
if (true) return left;
502-
}
503-
throw new Error("Missing return statement in function");
464+
return left;
504465
}
505466

506467
final public String stringLitteral() throws ParseException {
@@ -516,21 +477,15 @@ final public String stringLitteral() throws ParseException {
516477
i++;
517478
rc.append(c);
518479
}
519-
{
520-
if (true) return rc.toString();
521-
}
522-
throw new Error("Missing return statement in function");
480+
return rc.toString();
523481
}
524482

525483
final public PropertyExpression variable() throws ParseException {
526484
Token t;
527485
PropertyExpression left = null;
528486
t = jj_consume_token(ID);
529487
left = new PropertyExpression(t.image);
530-
{
531-
if (true) return left;
532-
}
533-
throw new Error("Missing return statement in function");
488+
return left;
534489
}
535490

536491
private boolean jj_2_1(int xla) {

0 commit comments

Comments
 (0)