Archive for April, 2009

Debugging the Fix

Posted in open-source, update on April 6, 2009 by nkhan26

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.

Fix by classmate

Posted in open-source, update on April 4, 2009 by nkhan26

Le Yang, along some background information and help by Kevin Vu, created a fix for bug 240698. Bug 240698 is exactly the same a my bug, just a different scenario. Even though the scenarios were different, the files related to the bugs were exactly the same. Using Le’s fix, mentioned on his blog, there was no second save dialogue prompt. Therefore, Le’s fix works for this bug as well.

I’ve tested this solution with different scenarios (multiple files, multiple servers), and it works fine. It seems that I was going about fixing this the wrong way. I was trying to link the SaveEditors method on the first prompt, to the saveDirty method in the second prompt (mentioned in a previous blog entry). One thing he did notice was that the saveEditors method was duplicated in prelaunch. Once this was understood, his solution sounds correct. I will be testing more, and give updates, but this was an excellent job by Le.

Follow

Get every new post delivered to your Inbox.