Skip to content

Commit 1d13be8

Browse files
Polishing
Get rid of exception in positional parameter detection.
1 parent 5b67e1e commit 1d13be8

File tree

1 file changed

+9
-5
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert

1 file changed

+9
-5
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,10 @@ protected String mapPropertyName(MongoPersistentProperty property) {
14901490

14911491
static boolean isPositionalParameter(String partial) {
14921492

1493+
if(!StringUtils.hasText(partial)) {
1494+
return false;
1495+
}
1496+
14931497
if ("$".equals(partial)) {
14941498
return true;
14951499
}
@@ -1499,12 +1503,12 @@ static boolean isPositionalParameter(String partial) {
14991503
return true;
15001504
}
15011505

1502-
try {
1503-
Long.valueOf(partial);
1504-
return true;
1505-
} catch (NumberFormatException e) {
1506-
return false;
1506+
for (int i = 0; i < partial.length(); i++) {
1507+
if (!Character.isDigit(partial.charAt(i))) {
1508+
return false;
1509+
}
15071510
}
1511+
return true;
15081512
}
15091513
}
15101514
}

0 commit comments

Comments
 (0)