You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bd...@apache.org on 2021/04/12 16:22:55 UTC

[shiro] branch master updated: Added closing for Scanner in TextConfigurationRealm

This is an automated email from the ASF dual-hosted git repository.

bdemers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f72d5e  Added closing for Scanner in TextConfigurationRealm
     new 7058994  Merge pull request #288 from pitjazz/bugfix-scanner
0f72d5e is described below

commit 0f72d5e47c2c09e16547964d9c90fd2a3adc83ae
Author: Piret Niva <pi...@iki.fi>
AuthorDate: Sun Mar 21 23:18:50 2021 +0200

    Added closing for Scanner in TextConfigurationRealm
---
 .../java/org/apache/shiro/realm/text/TextConfigurationRealm.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java b/core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java
index 0439f93..a33fbdd 100644
--- a/core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java
+++ b/core/src/main/java/org/apache/shiro/realm/text/TextConfigurationRealm.java
@@ -211,9 +211,10 @@ public class TextConfigurationRealm extends SimpleAccountRealm {
 
     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());
+            }
         }
         return set;
     }