Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Transactions] Issue with WorkspaceSynchronizer
[Transactions] Issue with WorkspaceSynchronizer [message #420116] Wed, 18 June 2008 12:40 Go to next message
Eclipse UserFriend
Originally posted by: twominutehate.joinpoint.org

Hi all.

In my (transactional) EMF based application all model manipulations by
the user are saved automatically using an Eclipse WorkspaceJob, which is
triggered by a "post commit listener". I'm using a WorkspaceSynchronizer
to detect "external" changes to the managed resources (a CVS update is
such an external change). I don't want it to receive any notifications,
when the auto-save job has finished, as there's no need to "synchronize"
then. To do this I've attached an IJobChangeListener to the AutoSave
job, which calls dispose() on the WorkspaceSynchronizer in its
aboutToRun() method, recreates the Synchronizer when the job is done and
the listener's done() method is called.

Now under unknown circumstances I'm getting the following exception:

java.lang.NullPointerException
at
org.eclipse.emf.workspace.util.MovedSynchRequest.doPerform(M ovedSynchRequest.java:45)
at org.eclipse.emf.workspace.util.SynchRequest$1.run(SynchReque st.java:53)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:262)
at org.eclipse.emf.workspace.util.SynchRequest.perform(SynchReq uest.java:51)
at
org.eclipse.emf.workspace.util.WorkspaceSynchronizer$Resourc eSynchJob.runInWorkspace(WorkspaceSynchronizer.java:512)
at
org.eclipse.core.internal.resources.InternalWorkspaceJob.run (InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

This exception only occurs occasionally, I can't reproduce it reliably :(

Any ideas?

Best regards,
Ömer
Re: [Transactions] Issue with WorkspaceSynchronizer [message #420117 is a reply to message #420116] Wed, 18 June 2008 13:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-DbfOA3GRpg1WZIn1A1k9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi, =C3=96mer,

The most likely reason for this NPE is the disposal of the
WorkspaceSynchronizer, which your job-listener does. Disposing the
synchronizer disposes its delegate and forgets it (resulting in the null
reference). Once disposed, you need to ensure that the synchronizer
will no longer be used for any purpose.

I suspect that there's a race between the ResourceSynchJob and your
listener, in which the synchronizer schedules the synch request before
it is disposed, then the synch request is performed later. Probably,
the SynchRequest should be tightened up to detect that its synchronizer
has been disposed and abandon its perform() method in that case. So,
please raise a bug for that.

However, I'm a little concerned by the need to dispose and re-create
these synchronizers. Perhaps you might rather implement a pause/resume
API on your synchronizer delegate.

Cheers,

Christian


On Wed, 2008-06-18 at 14:40 +0200, =C3=96mer Yildiz wrote:

> Hi all.
>=20
> In my (transactional) EMF based application all model manipulations by=20
> the user are saved automatically using an Eclipse WorkspaceJob, which is=20
> triggered by a "post commit listener". I'm using a WorkspaceSynchronizer=20
> to detect "external" changes to the managed resources (a CVS update is=20
> such an external change). I don't want it to receive any notifications,=20
> when the auto-save job has finished, as there's no need to "synchronize"=20
> then. To do this I've attached an IJobChangeListener to the AutoSave=20
> job, which calls dispose() on the WorkspaceSynchronizer in its=20
> aboutToRun() method, recreates the Synchronizer when the job is done and=20
> the listener's done() method is called.
>=20
> Now under unknown circumstances I'm getting the following exception:
>=20
> java.lang.NullPointerException
> at=20
> org.eclipse.emf.workspace.util.MovedSynchRequest.doPerform(M ovedSynchRequ=
est.java:45)
> at org.eclipse.emf.workspace.util.SynchRequest$1.run(SynchReque st.java:53=
)
> at=20
> org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclus=
ive(TransactionalEditingDomainImpl.java:262)
> at org.eclipse.emf.workspace.util.SynchRequest.perform(SynchReq uest.java:=
51)
> at=20
> org.eclipse.emf.workspace.util.WorkspaceSynchronizer$Resourc eSynchJob.run=
InWorkspace(WorkspaceSynchronizer.java:512)
> at=20
> org.eclipse.core.internal.resources.InternalWorkspaceJob.run (InternalWork=
spaceJob.java:38)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>=20
> This exception only occurs occasionally, I can't reproduce it reliably :(
>=20
> Any ideas?
>=20
> Best regards,
> =C3=96mer

--=-DbfOA3GRpg1WZIn1A1k9
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, &#214;mer,<BR>
<BR>
The most likely reason for this NPE is the disposal of the WorkspaceSynchronizer, which your job-listener does.&nbsp; Disposing the synchronizer disposes its delegate and forgets it (resulting in the null reference).&nbsp; Once disposed, you need to ensure that the synchronizer will no longer be used for any purpose.<BR>
<BR>
I suspect that there's a race between the ResourceSynchJob and your listener, in which the synchronizer schedules the synch request before it is disposed, then the synch request is performed later.&nbsp; Probably, the SynchRequest should be tightened up to detect that its synchronizer has been disposed and abandon its perform() method in that case.&nbsp; So, please raise a bug for that.<BR>
<BR>
However, I'm a little concerned by the need to dispose and re-create these synchronizers.&nbsp; Perhaps you might rather implement a pause/resume API on your synchronizer delegate.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Wed, 2008-06-18 at 14:40 +0200, &#214;mer Yildiz wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi all.</FONT>

<FONT COLOR="#000000">In my (transactional) EMF based application all model manipulations by </FONT>
<FONT COLOR="#000000">the user are saved automatically using an Eclipse WorkspaceJob, which is </FONT>
<FONT COLOR="#000000">triggered by a &quot;post commit listener&quot;. I'm using a WorkspaceSynchronizer </FONT>
<FONT COLOR="#000000">to detect &quot;external&quot; changes to the managed resources (a CVS update is </FONT>
<FONT COLOR="#000000">such an external change). I don't want it to receive any notifications, </FONT>
<FONT COLOR="#000000">when the auto-save job has finished, as there's no need to &quot;synchronize&quot; </FONT>
<FONT COLOR="#000000">then. To do this I've attached an IJobChangeListener to the AutoSave </FONT>
<FONT COLOR="#000000">job, which calls dispose() on the WorkspaceSynchronizer in its </FONT>
<FONT COLOR="#000000">aboutToRun() method, recreates the Synchronizer when the job is done and </FONT>
<FONT COLOR="#000000">the listener's done() method is called.</FONT>

<FONT COLOR="#000000">Now under unknown circumstances I'm getting the following exception:</FONT>

<FONT COLOR="#000000">java.lang.NullPointerException</FONT>
<FONT COLOR="#000000">at </FONT>
<FONT COLOR="#000000"> org.eclipse.emf.workspace.util.MovedSynchRequest.doPerform(M ovedSynchRequest.java:45) </FONT>
<FONT COLOR="#000000">at org.eclipse.emf.workspace.util.SynchRequest$1.run(SynchReque st.java:53) </FONT>
<FONT COLOR="#000000">at </FONT>
<FONT COLOR="#000000"> org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:262) </FONT>
<FONT COLOR="#000000">at org.eclipse.emf.workspace.util.SynchRequest.perform(SynchReq uest.java:51) </FONT>
<FONT COLOR="#000000">at </FONT>
<FONT COLOR="#000000"> org.eclipse.emf.workspace.util.WorkspaceSynchronizer$Resourc eSynchJob.runInWorkspace(WorkspaceSynchronizer.java:512) </FONT>
<FONT COLOR="#000000">at </FONT>
<FONT COLOR="#000000"> org.eclipse.core.internal.resources.InternalWorkspaceJob.run (InternalWorkspaceJob.java:38) </FONT>
<FONT COLOR="#000000">at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)</FONT >

<FONT COLOR="#000000">This exception only occurs occasionally, I can't reproduce it reliably :(</FONT>

<FONT COLOR="#000000">Any ideas?</FONT>

<FONT COLOR="#000000">Best regards,</FONT>
<FONT COLOR="#000000">&#214;mer</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-DbfOA3GRpg1WZIn1A1k9--
Re: [Transactions] Issue with WorkspaceSynchronizer [message #420118 is a reply to message #420117] Wed, 18 June 2008 13:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: twominutehate.joinpoint.org

Hi Christian,

> However, I'm a little concerned by the need to dispose and re-create
> these synchronizers. Perhaps you might rather implement a pause/resume
> API on your synchronizer delegate.

I already did that as a "workaround" for the problem, but perhaps it's
the better way to do it actually :)

Btw do you know, whether I can be sure that the WorkspaceSynchronizer
never receives workspace modifications made by the Autosave
WorkspaceJob, after resuming the synchronizer in the Job listener's
done() method?
I mean, is there a chance that the workspace sends the resource
modification notifications after the WorkspaceJob has finished and the
done() method is called?


Thank you very much!
Re: [Transactions] Issue with WorkspaceSynchronizer [message #420138 is a reply to message #420118] Thu, 19 June 2008 01:06 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-QCBkm7UF3Nxhtypj/tJS
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi, =C3=96mer,

I think that's the point of the WorkspaceJob: that it only sends
resource change notifications after the job is completed.

Although, I will admit that I don't know how the timing of the
listener's done() method invocation relates to the dispatching of the
resource changes.

Cheers,

Christian


On Wed, 2008-06-18 at 15:33 +0200, =C3=96mer Yildiz wrote:

> Hi Christian,
>=20
> > However, I'm a little concerned by the need to dispose and re-create=20
> > these synchronizers. Perhaps you might rather implement a pause/resume=
=20
> > API on your synchronizer delegate.
>=20
> I already did that as a "workaround" for the problem, but perhaps it's=20
> the better way to do it actually :)
>=20
> Btw do you know, whether I can be sure that the WorkspaceSynchronizer=20
> never receives workspace modifications made by the Autosave=20
> WorkspaceJob, after resuming the synchronizer in the Job listener's=20
> done() method?
> I mean, is there a chance that the workspace sends the resource=20
> modification notifications after the WorkspaceJob has finished and the=20
> done() method is called?
>=20
>=20
> Thank you very much!

--=-QCBkm7UF3Nxhtypj/tJS
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, &#214;mer,<BR>
<BR>
I think that's the point of the WorkspaceJob:&nbsp; that it only sends resource change notifications after the job is completed.<BR>
<BR>
Although, I will admit that I don't know how the timing of the listener's done() method invocation relates to the dispatching of the resource changes.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Wed, 2008-06-18 at 15:33 +0200, &#214;mer Yildiz wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi Christian,</FONT>

<FONT COLOR="#000000">&gt; However, I'm a little concerned by the need to dispose and re-create </FONT>
<FONT COLOR="#000000">&gt; these synchronizers. Perhaps you might rather implement a pause/resume </FONT>
<FONT COLOR="#000000">&gt; API on your synchronizer delegate.</FONT>

<FONT COLOR="#000000">I already did that as a &quot;workaround&quot; for the problem, but perhaps it's </FONT>
<FONT COLOR="#000000">the better way to do it actually :)</FONT>

<FONT COLOR="#000000">Btw do you know, whether I can be sure that the WorkspaceSynchronizer </FONT>
<FONT COLOR="#000000">never receives workspace modifications made by the Autosave </FONT>
<FONT COLOR="#000000">WorkspaceJob, after resuming the synchronizer in the Job listener's </FONT>
<FONT COLOR="#000000">done() method?</FONT>
<FONT COLOR="#000000">I mean, is there a chance that the workspace sends the resource </FONT>
<FONT COLOR="#000000">modification notifications after the WorkspaceJob has finished and the </FONT>
<FONT COLOR="#000000">done() method is called?</FONT>


<FONT COLOR="#000000">Thank you very much!</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-QCBkm7UF3Nxhtypj/tJS--
Previous Topic:what is a resource?
Next Topic:excellent code quality
Goto Forum:
  


Current Time: Thu Apr 25 13:44:44 GMT 2024

Powered by FUDForum. Page generated in 0.02716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top