Index: applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java
===================================================================
--- applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java	(revision 30737)
+++ applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java	(revision 30738)
@@ -49,4 +49,5 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import org.netbeans.spi.keyring.KeyringProvider;
 
@@ -69,7 +70,7 @@
         }
         CommandResult result = runCommand("isEnabled");
-        if(new String(result.retVal).equals("true")) {        
+        if(new String(result.retVal).equals("true")) {
             return updateHandler();
-        }                   
+        }
         return false;
     };
@@ -121,15 +122,15 @@
         }
         handler = new String(handler).equals("")? "0".toCharArray() : handler;
-        CommandResult result = runCommand("isOpen",handler);          
+        CommandResult result = runCommand("isOpen",handler);
         if(new String(result.retVal).equals("true")){
             return true;
         }
         char[] localWallet = defaultLocalWallet;
-        result = runCommand("localWallet");                      
-        if(result.exitCode == 0) {                    
+        result = runCommand("localWallet");
+        if(result.exitCode == 0) {
             localWallet = result.retVal;
         }
-            
-        if(new String(localWallet).contains(".service")) {            
+
+        if(new String(localWallet).contains(".service")) {
             //Temporary workaround for the bug in kdelibs/kdeui/util/kwallet.cpp
             //The bug was fixed http://svn.reviewboard.kde.org/r/5885/diff/
@@ -138,19 +139,19 @@
         }
         result = runCommand("open", localWallet , "0".toCharArray(), getApplicationName(true));
-        if(result.exitCode == 2) { 
+        if(result.exitCode == 2) {
             warning("time out happened while accessing KWallet");
             //don't try to open KWallet anymore until bug https://bugs.kde.org/show_bug.cgi?id=259229 is fixed
             timeoutHappened = true;
             return false;
-        }      
+        }
         if(result.exitCode != 0 || new String(result.retVal).equals("-1")) {
             warning("failed to access KWallet");
             return false;
-        }         
+        }
         handler = result.retVal;
         return true;
     }
-          
-    
+
+
 
     private CommandResult runCommand(String command,char[]... commandArgs) {
@@ -174,24 +175,23 @@
             }
             Process pr = rt.exec(argv);
-            
-            BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
-
             String line;
-            while((line = input.readLine()) != null) {
-                if (!retVal.equals("")){
-                    retVal = retVal.concat("\n");
+
+            try (BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()))) {
+                while((line = input.readLine()) != null) {
+                    if (!retVal.equals("")){
+                        retVal = retVal.concat("\n");
+                    }
+                    retVal = retVal.concat(line);
                 }
-                retVal = retVal.concat(line);
-            }            
-            input.close();
-            input = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
-
-            while((line = input.readLine()) != null) {
-                if (!errVal.equals("")){
-                    errVal = errVal.concat("\n");
+            }
+
+            try (BufferedReader input = new BufferedReader(new InputStreamReader(pr.getErrorStream()))) {
+                while((line = input.readLine()) != null) {
+                    if (!errVal.equals("")){
+                        errVal = errVal.concat("\n");
+                    }
+                    errVal = errVal.concat(line);
                 }
-                errVal = errVal.concat(line);
-            }
-            input.close();
+            }
 
             exitCode = pr.waitFor();
@@ -199,5 +199,5 @@
                 logger.log(Level.FINE, "application exit with code {0} for commandString: {1}; errVal: {2}",
                             new Object[]{exitCode, Arrays.toString(argv), errVal});
-            }       
+            }
         } catch (InterruptedException ex) {
             logger.log(Level.FINE,
@@ -210,5 +210,5 @@
         }
         return new CommandResult(exitCode, retVal.trim().toCharArray(), errVal.trim());
-    }    
+    }
 
     private char[] getApplicationName(){
@@ -222,16 +222,14 @@
     private void warning(String descr) {
         logger.log(Level.WARNING, "Something went wrong: {0}", descr);
-    }      
-  
+    }
+
     private class CommandResult {
         private int exitCode;
         private char[] retVal;
-        private String errVal;
 
         public CommandResult(int exitCode, char[] retVal, String errVal) {
             this.exitCode = exitCode;
             this.retVal = retVal;
-            this.errVal = errVal;
-        }                        
+        }
     }
 
