pitjazz commented on a change in pull request #288:
URL: https://github.com/apache/shiro/pull/288#discussion_r602789211
##########
File path:
core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java
##########
@@ -211,9 +215,15 @@ protected void processUserDefinitions(Map<String, String>
userDefs) {
protected static Set<String> toLines(String s) {
LinkedHashSet<String> set = new LinkedHashSet<String>();
- Scanner scanner = new Scanner(s);
- while (scanner.hasNextLine()) {
- set.add(scanner.nextLine());
+ try (Scanner scanner = new Scanner(s)) {
+ while (scanner.hasNextLine()) {
+ set.add(scanner.nextLine());
+ }
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ String msg = "Unable to fetch next line, Scanner stream
corrupted.";
+ log.warn(msg, e);
+ }
Review comment:
I removed the catch block, updated the pull request. What I want to do
is just close the scanner and catch is not needed for that.
I also removed the unit test. There is no need to test how scanner reads the
nextLine, because reading of users and roles are already tested in
TextConfigurationRealmTest. Perhaps closing the scanner could be tested, but
IMHO it's not relevant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]