[rfc][icedtea-web] PolicyEditor NPE-on-save fix

Omair Majid omajid at redhat.com
Tue Jun 3 14:28:24 UTC 2014


* Andrew Azores <aazores at redhat.com> [2014-05-21 09:52]:

> +++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
> @@ -479,6 +479,14 @@ public class PolicyEditor extends JPanel
>              if (editor.changesMade) {
>                  final int save = JOptionPane.showConfirmDialog(this, R("PESaveChanges"));
>                  if (save == JOptionPane.YES_OPTION) {
> +                    if (editor.file == null) {
> +                        final int choice = editor.fileChooser.showSaveDialog(this);
> +                        if (choice == JFileChooser.APPROVE_OPTION) {
> +                            editor.file = editor.fileChooser.getSelectedFile();
> +                        } else if (choice == JFileChooser.CANCEL_OPTION) {
> +                            return;
> +                        }
> +                    }
>                      editor.savePolicyFile();
>                  } else if (save == JOptionPane.CANCEL_OPTION) {
>                      return;
> @@ -544,6 +552,14 @@ public class PolicyEditor extends JPanel
>              if (editor.changesMade) {
>                  final int save = JOptionPane.showConfirmDialog(this, R("PESaveChanges"));
>                  if (save == JOptionPane.YES_OPTION) {
> +                    if (editor.file == null) {
> +                        final int choice = editor.fileChooser.showSaveDialog(this);
> +                        if (choice == JFileChooser.APPROVE_OPTION) {
> +                            editor.file = editor.fileChooser.getSelectedFile();
> +                        } else if (choice == JFileChooser.CANCEL_OPTION) {
> +                            return;
> +                        }
> +                    }
>                      editor.savePolicyFile();
>                  } else if (save == JOptionPane.CANCEL_OPTION) {
>                      return;

Does it make sense to move these duplicated lines of code into a shared
method?

Thanks,
Omair

-- 
PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681


More information about the distro-pkg-dev mailing list