Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339293 - Model references are incremented when document is null
Summary: Model references are incremented when document is null
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.sse (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-08 17:34 EST by Leo Dos Santos CLA
Modified: 2011-10-18 14:08 EDT (History)
2 users (show)

See Also:


Attachments
patch (1.67 KB, patch)
2011-10-12 17:17 EDT, Nick Sandonato CLA
no flags Details | Diff
updated patch (4.23 KB, patch)
2011-10-18 14:04 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Dos Santos CLA 2011-03-08 17:34:13 EST
We're observing a concurrency issue in our client code and we're not sure if its exposing an issue in ModelManagerImpl. We have some tests that open a structured editor and perform some edits, then close the editor and check that the model references are returned to 0. Occasionally the tests are off by 1, and we have been observing that the FileBufferModelManager.connect method is logging an exception because the document it is passed is null. The model reference count is being incremented before FileBufferModelManager does its work and before ModelManagerImpl returns the shared model.

Should the _incrCount and _decrCount methods only be increasing/decreasing the reference count based on whether the FiledBufferModelManager.connect result is successful? And should the model getters return null if the FileBufferModelManager can't connect?
Comment 1 Leo Dos Santos CLA 2011-03-08 19:27:01 EST
I mean to include a stack trace that shows the relevant methods in ModelManagerImpl

!ENTRY org.eclipse.wst.sse.core 4 4 2011-03-05 23:11:16.686
!MESSAGE can not connect() without a document
java.lang.IllegalArgumentException: can not connect() without a document
at org.eclipse.wst.sse.core.internal.FileBufferModelManager.connect(FileBufferModelManager.java:423)
at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl._incrCount(ModelManagerImpl.java:665)
at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.getExistingModelForRead(ModelManagerImpl.java:1302)
at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.getExistingModelForRead(ModelManagerImpl.java:1269)
at org.springframework.ide.eclipse.aop.core.internal.model.builder.AspectDefinitionBuilderHelper$DefaultDocumentFactory.createDocument(AspectDefinitionBuilderHelper.java:116)
at org.springframework.ide.eclipse.security.core.aop.model.builder.SecurityXmlAspectDefinitionBuilder.buildAspectDefinitions(SecurityXmlAspectDefinitionBuilder.java:66)
at org.springframework.ide.eclipse.aop.core.internal.model.builder.AspectDefinitionBuilderHelper.buildAspectDefinitions(AspectDefinitionBuilderHelper.java:90)
at org.springframework.ide.eclipse.aop.core.internal.model.builder.AopReferenceModelBuilderJob.buildAspectDefinitions(AopReferenceModelBuilderJob.java:399)
build	05-Mar-2011 23:11:16	 at org.springframework.ide.eclipse.aop.core.internal.model.builder.AopReferenceModelBuilderJob.buildAopReferencesForFile(AopReferenceModelBuilderJob.java:328)
at org.springframework.ide.eclipse.aop.core.internal.model.builder.AopReferenceModelBuilderJob.buildAopModel(AopReferenceModelBuilderJob.java:442)
at org.springframework.ide.eclipse.aop.core.internal.model.builder.AopReferenceModelBuilderJob.run(AopReferenceModelBuilderJob.java:159)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 2 Nick Sandonato CLA 2011-03-10 08:24:41 EST
Hi, Leo. Thanks for opening this.

Ultimately, we'd want to fix the concurrency issue and then hopefully the reference counts will fall back into line. Is it possible to attach a reproducible scenario that we could get to the bottom of?

Returning null for the model and cleaning up the sharedObject might be safer in the end than returning a model with no document.
Comment 3 Leo Dos Santos CLA 2011-03-29 18:34:48 EDT
Hello Nick. I was never able to come up with a reproducible case. Upon further investigation I've discovered that the stack trace I posted occurs at random on a subset of our tests, but does not occur during our model count test as I first suggested. I've been able to verify that the model reference count does eventually return to 0, despite not always reporting so the first time.

I'm still not sure what the conditions are that would be causing the stack trace above to occur, but it could just be a poorly formed test case on our part. I'd be okay with closing this as invalid if you don't think there needs to be any modifications to ModelManagerImpl
Comment 4 Nick Sandonato CLA 2011-10-12 17:17:57 EDT
Created attachment 205070 [details]
patch

I believe this may be a race condition when invoking the _incrCount from the getExistingModelForEdit[Read](Object) as it was not properly guarded by the SYNC lock.
Comment 5 Nick Sandonato CLA 2011-10-18 14:04:20 EDT
Created attachment 205448 [details]
updated patch
Comment 6 Nick Sandonato CLA 2011-10-18 14:08:51 EDT
Code released to HEAD.