Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] notifyAll exception

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[quote Irum Godil::on 2/4/2005 4:37 AM]
| Hi,
| I have a synchronized function which has a call to notifyAll. I want to put both the synchronized
keyword and the call to notifyAll into an aspect. I have done the following:
|
|
| pointcut writeObjectExec(DurableOutputStream stream) : target(stream) &&
|                                 execution(int writeObject(Object) throws IOException);
|
|
| int around(DurableOutputStream stream) : writeObjectExec(stream) {
|       synchronized(stream) {
|       return proceed(stream);
|   }
|  }
| This gets rid of the "synchronized" keyword. Now I do the following:
|
| pointcut writeObjectCut() : withincode(private int writeObject(Object) throws IOException)
|  && within(DurableOutputStream) && set(int DurableOutputStream._objectsWritten);
|
| after() : writeObjectCut() {
|      notifyAll();
|  }
|
| However, I keep getting the exception "Current Thread not owner". The exception is happening
around the "notifyAll" call. Can someone please help me as to what to do here?
|
| Thanks.
| Sincerely,
| Irum Godil.

Hi,

The notifyAll() call must occur on the locked object (the DurableOutputStream) and not on the aspect
object (as it is happening in the 2nd advice of yours).

However I cannot see why are you in need to use the notifyAll(). The lock on DurableOutputStream is
released after the execution of proceed(...) (so it is release after the finish of your around advice).

- --
:alex |.::the_mindstorm::.|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCAxahTTDTje0R2dgRAoXoAJ9pz2Hpw4NSrUGblUUNQXYutMiLKwCcDE9i
CVKP2apsCDuG0898UH5WBrs=
=IVeW
-----END PGP SIGNATURE-----


Back to the top