Skip to content

Commit

Permalink
nullcheck for startsWith method
Browse files Browse the repository at this point in the history
  • Loading branch information
Antiik91 committed Aug 26, 2022
1 parent 27bc21d commit b7d3fdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public static Instant getTimeOrNow(long epochSeconds) {
}

public static boolean startsWith(String str, String name, Locale locale) {
return str.toLowerCase(locale).startsWith(name);
return str != null && str.toLowerCase(locale).startsWith(name);
}

public static boolean startsWith(I18NString str, String name, Locale locale) {
return str.toString(locale).toLowerCase(locale).startsWith(name);
return str != null && str.toString(locale).toLowerCase(locale).startsWith(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -909,18 +909,10 @@ public DataFetcher<Iterable<Route>> routes() {
if (args.getLegacyGraphQLName() != null) {
String name = args.getLegacyGraphQLName().toLowerCase(environment.getLocale());
routeStream =
routeStream.filter(route -> {
if (
route.getShortName() != null &&
LegacyGraphQLUtils.startsWith(route.getShortName(), name, environment.getLocale())
) {
return true;
}
return (
route.getLongName() != null &&
LegacyGraphQLUtils.startsWith(route.getLongName(), name, environment.getLocale())
);
});
routeStream.filter(route ->
LegacyGraphQLUtils.startsWith(route.getShortName(), name, environment.getLocale()) ||
LegacyGraphQLUtils.startsWith(route.getLongName(), name, environment.getLocale())
);
}
return routeStream.collect(Collectors.toList());
};
Expand Down

0 comments on commit b7d3fdb

Please sign in to comment.