Wednesday, April 1, 2009

Fixed Bug 240698 - Part I

At the beginning of this course, I want to fix the bug 243799. After I investigated the bug and posted my analysis in Bugzilla and newsgroup, no one replies me. Therefore, I decide to change my bug. I choose the bug 240698 from the bug list that proposed by Jordan.

Kevin Vu, one of my classmate recently work on this bug and post some analysis in his blog

From reading Kevin's blog, I get a lot of hints.

Here is what causes the bug and how do I solve it.

Cause of the Bug
The Save Source Window pops up twice to ask user to save the modification.
In the StartAction, method
void start(IServer server, String launchMode, final Shell shell)
if (!ServerUIPlugin.saveEditors()) (Step 1)
server.start(launchMode, (IOperationListener)null); (Step 2)

The ServerUIPlugin.saveEditors() (In Step 1) asks the user to Save Source before the server get launched (In Step 2).

The user makes a selection in the first Pop Up Save Source Dialog (Yes, No, Cancel)

For our case, I choose No in the Pop Up Save Source Dialog

and then the server is going to launch by calling server.start(launchMode, (IOperationListener)null); (Step 2)

In the org.eclipse.debug.core.ILaunchConfiguration
launch(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean, boolean) method

there is progress monitor thread which monitor the Server Launch

Setup progress monitor
Step 1 * - Prepare delegate (0)
Step 2 * - Pre-launch check (1)
Step 3 * - [Build before launch (7)] if build
Step 4 * - [Incremental build before launch (3)] if build
Step 5 * - Final launch validation (1)
Step 6 * - Initialize source locator (1)
Step 7 * - Launch delegate (10) */

In the Step2, Pre-Launch check, it is a CLASS file. When the pre-launch runs, it will ask the user to save any changes if there is any modification in the server editor. Because in the first Pop-up Save Source Window, we choose NO, the pre-Launch will ask the user to save it again. If the user choose yes in the first Save Source Dialog, the pre-Launch will not ask the user to save it because there is no modification in the server editor. This explains why the Save Source Dialog pop up twice when we clicks NO in the first Save Source Dialog.

Solution to the Bug

Two Changes:
1. Get rid of if (!ServerUIPlugin.saveEditors())
it is duplicated with the pre-Launch
2. If we get rid of the code above, it will cause another problem. What if we choose cancel button from the Save Source Dialog in the pre-Launch. The pre-Launch will be interrupted and return Launch to the Server Class.
It will cause IStatus startImpl(String launchMode, IProgressMonitor monitor) throw a error message
I add a constrain to the condtion if (!monitor.isCanceled() && getServerState() == IServer.STATE_STOPPED && getLaunch().getSourceLocator() != null). It seems work

Beyond this bug, I find something is odd. If I add a new server and use the default ports to start the server (Default Port Number Below), the server will throw a CoreException (See Screen Below)
Tomcat Admin: 8005
Http/1.1: 8080

I will post this concern in the newsgroup later and create a fixed patch for the bug 240698 (hopefully run unit test before upload it) .


  1. Hi, Yang.

    Wonderful! Please keep everyone posted.


  2. Yang,

    I am glad that we have also good news (we can see the light at the end of ...)

    Congratulations! Keep up with your good work


  3. awesome, Le! what a relieve :)! I was all thinking in other direction (trying to change isDirty to false for all dirty fields)

  4. Excellent job Le! My bug is exactly related to this. Nice way of thinking!