/hg/icedtea-web: PolicyEditor: avoid NPE when saving to a new file

aazores at icedtea.classpath.org aazores at icedtea.classpath.org
Thu Mar 13 15:52:22 UTC 2014


changeset abec2ce76cdb in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=abec2ce76cdb
author: Andrew Azores <aazores at redhat.com>
date: Thu Mar 13 11:52:14 2014 -0400

	PolicyEditor: avoid NPE when saving to a new file

	* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java:
	(savePolicyFile, updateMd5WithDialog) avoid NPE when saving to a new file


diffstat:

 ChangeLog                                                         |  5 +++++
 netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java |  9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diffs (38 lines):

diff -r 71a87178ff7e -r abec2ce76cdb ChangeLog
--- a/ChangeLog	Thu Mar 13 16:43:45 2014 +0100
+++ b/ChangeLog	Thu Mar 13 11:52:14 2014 -0400
@@ -1,3 +1,8 @@
+2014-03-13  Andrew Azores  <aazores at redhat.com>
+
+	* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java:
+	(savePolicyFile, updateMd5WithDialog) avoid NPE when saving to a new file
+
 2014-03-13  Jiri Vanek  <jvanek at redhat.com>
 
 	* tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java: adapted
diff -r 71a87178ff7e -r abec2ce76cdb netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Thu Mar 13 16:43:45 2014 +0100
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Thu Mar 13 11:52:14 2014 -0400
@@ -984,6 +984,9 @@
 
                 try {
                     FileUtils.saveFile(sb.toString(), file);
+                    if (fileWatcher == null) {
+                        fileWatcher = new MD5SumWatcher(file);
+                    }
                     fileWatcher.update();
                     changesMade = false;
                     showChangesSavedDialog();
@@ -1026,6 +1029,12 @@
      * @throws IOException if the file cannot be read
      */
     public int updateMd5WithDialog() throws FileNotFoundException, IOException {
+        if (fileWatcher == null) {
+            if (file != null) {
+                fileWatcher = new MD5SumWatcher(file);
+            }
+            return JOptionPane.NO_OPTION;
+        }
         final boolean changed = fileWatcher.update();
         if (changed) {
             return JOptionPane.showConfirmDialog(weakThis.get(), R("PEFileModifiedDetail", file.getCanonicalPath()),


More information about the distro-pkg-dev mailing list