bdemers commented on a change in pull request #288:
URL: https://github.com/apache/shiro/pull/288#discussion_r599024538



##########
File path: 
core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java
##########
@@ -211,11 +212,14 @@ 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());
-        }
-        return set;
+               try (Scanner scanner = new Scanner(s)) {
+                       while (scanner.hasNextLine()) {
+                               set.add(scanner.nextLine());
+                       }
+               } catch (NoSuchElementException e) {
+                       e.printStackTrace();
+               } 
+               return set;

Review comment:
       The rest of the file is formatted with spaces, this blog looks like 
tabs? can you fix that?
   
   Instead of `e.printStackTrace()` use a logger.
   
   More importantly though, how was this the exception triggered?  I'm guessing 
if `hasNextLine()` returns true, and then `.nextLine()` throws a 
`NoSuchElementException`, that's not an error you would want to recover from, 
as the stream would have been corrupted?  And in this case potentially worse 
because we are operating against a String in memory, which means things have 
gone severely wrong?
   
   I could be miss understanding something here though, I only took a quick 
look.




-- 
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]


Reply via email to