Debugging the Fix

I’ve created and uploaded a patch for bug 227760, and also a wiki page.

Debugging with the fix, signals a slight different behaviour in the way classes are called upon. Since the

if (!ServerUIPlugin.saveEditors())
               return;

is not being used anymore, the classes are called a bit differently. Previously, you started at the “start(server, launchMode, shell);” in StartACtion.java, before going to the “if” condition mentioned above. This condition led to the “ServerUIPlugin.java” class, then to “Server.java” class breifly, then to the “ServerUIPreferences.java” class (see post: Bug 227760 Source Code Location for more details). When this was was implemented, the “ServerUIPlugin.java” class led to various preference classes being called upon, before the first prompt is received. This being is being carried out in the “SaveEditors()” method:

public static boolean saveEditors() {
        byte b = ServerUIPlugin.getPreferences().getSaveEditors();
        if (b == ServerUIPreferences.SAVE_EDITORS_NEVER)
            return true;
        return ServerUIPlugin.getInstance().getWorkbench().saveAllEditors(b == ServerUIPreferences.SAVE_EDITORS_PROMPT);
}

This then led to the return statement, before finishing the “start(IServer server, String launchMode, final Shell shell)” method in “StartAction.java”. This then led from the “StartAction.java” class, to the “Server.java” class, then to various preferences class (like EclipsePreference.class), then to “handleStatus(IStatus status, Object source)” method in the “SaveScopeResourceHandler.java”, which led to the second prompt.

When the fix was applied, the behaviour was more like the latter behaviour mentioned. Since there is no “if (!ServerUIPlugin.saveEditors())”, the “ServerUIPlugin.java” class is not called upon. This is what removes the first “save dialogue”, and the latter behaviour ensues. Therefore, the “StartAction.java” class is called upon, which leads to the “Server.java” class, which goes through various prefrences “.class” files, which leads to the “SaveResourceHandler.java”, which leads to the “DebugUIPlugin.java”, where the preLaunchSave method checks and calls for the save dialogue prompt:

public static boolean preLaunchSave() {
        String saveDirty = getDefault().getPreferenceStore().getString(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH);
        if (saveDirty.equals(MessageDialogWithToggle.NEVER)) {
            return true;
        }
        return saveAllEditors(saveDirty.equals(MessageDialogWithToggle.PROMPT));
}

This shows exactly the effect of making the changes to the “StartAction.java” to remove the uneccesary check. The methods being called in the “ServerUIPlugin.java” class, and the “ServerUIPreferences.java” class, are all related to saving open editors. Other methods in these two classes are not being used for this step. Since the save dialogue is prompted later in the pre-launch, the first check is not required. Therefore, thepatch, that was attached through bugzilla, should be a possible fix.

Leave a comment