Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319642

Summary: StructuredTextEditor may complete model lifecycle on a different model
Product: [WebTools] WTP Source Editing Reporter: Nick Sandonato <nsand.dev>
Component: wst.sseAssignee: Nick Sandonato <nsand.dev>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: david_williams
Version: 3.2Flags: david_williams: pmc_approved+
nsand.dev: pmc_approved? (raghunathan.srinivasan)
nsand.dev: pmc_approved? (naci.dai)
deboer: pmc_approved+
nsand.dev: pmc_approved? (neil.hauge)
nsand.dev: pmc_approved? (kaloyan)
thatnitind: review+
Target Milestone: 3.2.1   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved WI50430
Attachments:
Description Flags
patch none

Description Nick Sandonato CLA 2010-07-12 17:39:13 EDT
The StructuredTextEditor may complete the model lifecycle on a different model during doSave(). Initially, the internal model is notified that it is about to be changed. But, upon saving, it is possible for the input to have been deleted, which would cause a saveAs() to set the new input for the editor creating a new internal model in the process. When the finally clause is reached in the doSave(), the editor completes the lifecycle on the new model instead of the old.
Comment 1 Nick Sandonato CLA 2010-07-12 17:41:00 EDT
Created attachment 174105 [details]
patch
Comment 2 Nick Sandonato CLA 2010-07-13 10:17:26 EDT
Nitin, would you mind taking a look at this for 3.2.1?
Comment 3 Nick Sandonato CLA 2010-07-13 13:34:09 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such.

The primary issue with this is that the wrong model is notified that changes to it have been completed. This causes a couple of things to occur:

1. The lock guarding both the structured document and model is over-released, which may cause synchronization problems between the model and document
2. The model will fire off notifications to its model state listeners signaling that the model has changed, when it fact it hasn't. This can give the listeners the wrong idea about the current state of the model and may result in errors (model changed without model about to change notification).

* Is there a work-around? If so, why do you believe the work-around is insufficient?

No.

* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?

Existing unit tests have been run as well as manual testing.

* Give a brief technical overview. Who has reviewed this fix?

The editor always managed the lifecycle of its current model during a save. In the case where a save could lead to a save as (e.g., original file could not be written to), the model changes since the editor's input changes. This resulted in the finalizing of the model's life cycle to be executed on the wrong model.

This fix makes sure that finalizing the model's life cycle is done on the same model that the editor started with.

Nitin has reviewed the fix.

* What is the risk associated with this fix?

Almost none. Just guaranteeing that we use the same model through the lifecycle calls.
Comment 4 Nick Sandonato CLA 2010-07-14 13:36:12 EDT
Released to Maintenance and HEAD.