public void _saveSettings() { // public for testing purposes
   if (mySaveSettingsIsInProgress.compareAndSet(false, true)) {
     try {
       StoreUtil.doSave(getStateStore());
     } catch (final Throwable ex) {
       if (isUnitTestMode()) {
         System.out.println("Saving application settings failed");
         ex.printStackTrace();
       } else {
         LOG.info("Saving application settings failed", ex);
         invokeLater(
             new Runnable() {
               public void run() {
                 if (ex instanceof PluginException) {
                   final PluginException pluginException = (PluginException) ex;
                   PluginManager.disablePlugin(pluginException.getPluginId().getIdString());
                   Messages.showMessageDialog(
                       "The plugin "
                           + pluginException.getPluginId()
                           + " failed to save settings and has been disabled. Please restart "
                           + ApplicationNamesInfo.getInstance().getFullProductName(),
                       CommonBundle.getErrorTitle(),
                       Messages.getErrorIcon());
                 } else {
                   Messages.showMessageDialog(
                       ApplicationBundle.message(
                           "application.save.settings.error", ex.getLocalizedMessage()),
                       CommonBundle.getErrorTitle(),
                       Messages.getErrorIcon());
                 }
               }
             });
       }
     } finally {
       mySaveSettingsIsInProgress.set(false);
     }
   }
 }