Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Transient interceptors not being released

Received: by 10.66.77.131 with SMTP id s3mr142010paw.24.1352192657527;
        Tue, 06 Nov 2012 01:04:17 -0800 (PST)
X-BeenThere: castle-project-users@googlegroups.com
Received: by 10.68.236.33 with SMTP id ur1ls720067pbc.2.gmail; Tue, 06 Nov
 2012 01:04:15 -0800 (PST)
Received: by 10.66.85.168 with SMTP id i8mr139743paz.21.1352192655222;
        Tue, 06 Nov 2012 01:04:15 -0800 (PST)
Received: by 10.66.85.168 with SMTP id i8mr139742paz.21.1352192655207;
        Tue, 06 Nov 2012 01:04:15 -0800 (PST)
Return-Path: <krzysztof.koz...@gmail.com>
Received: from mail-da0-f49.google.com (mail-da0-f49.google.com [209.85.210.49])
        by gmr-mx.google.com with ESMTPS id m8si4512051pav.2.2012.11.06.01.04.15
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 06 Nov 2012 01:04:15 -0800 (PST)
Received-SPF: pass (google.com: domain of krzysztof.koz...@gmail.com designates 209.85.210.49 as permitted sender) client-ip=209.85.210.49;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of krzysztof.koz...@gmail.com designates 209.85.210.49 as permitted sender) smtp.mail=krzysztof.koz...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-da0-f49.google.com with SMTP id q27so113284daj.8
        for <castle-project-users@googlegroups.com>; Tue, 06 Nov 2012 01:04:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:x-mailer
         :mime-version:content-type;
        bh=elOj9z7C6pdxkDSuk8o04kTT98px51ZvZQmK1ak40a8=;
        b=PaNyAFDTQVCPryTLY2GknY1fFZ2lH+NNxxP/39mRUGsF9YVbUDwiwgFN9plu7PNCdS
         b7uvmBcAvNwHhnZqpVklGCvganYhzXl9LxJCSsOeCvpHiYyKTenzMW9Bx9vyU6TSqdKH
         cmnoncGThJP8kZWzdUocJ4Qhue59fPYTOuaRXovIYXMH3v6kFeiYTvFxqU64EKaEVf/X
         kHxLoBzJ3SC9tkm1vrkUC32DGX+HkG5A97M16psys1+d4t/uMs4TFjmJffnlnOkFDelZ
         DtMEwO3HhCs/lvexIaaYmZ6NJWMT0OhPKpe5eW2GHVDYc7DkJIVeSaImCqkFm9B2XFJ3
         q9sA==
Received: by 10.68.135.101 with SMTP id pr5mr1262468pbb.140.1352192654331;
        Tue, 06 Nov 2012 01:04:14 -0800 (PST)
Return-Path: <krzysztof.koz...@gmail.com>
Received: from [192.168.1.123] (203-219-147-58.tpgi.com.au. [203.219.147.58])
        by mx.google.com with ESMTPS id sf4sm12031075pbc.75.2012.11.06.01.04.11
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 06 Nov 2012 01:04:13 -0800 (PST)
Date: Tue, 6 Nov 2012 19:04:06 +1000
From: Krzysztof Kozmic <krzysztof.koz...@gmail.com>
To: castle-project-users@googlegroups.com
Message-ID: <60EFC23F47944D60BED224BC7F11D...@gmail.com>
In-Reply-To: <A20B54A4-9861-4E35-A3A6-0032E9DC7...@gmail.com>
References: <A20B54A4-9861-4E35-A3A6-0032E9DC7...@gmail.com>
Subject: Re: Transient interceptors not being released
X-Mailer: sparrow 1.6.4 (build 1178)
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="5098d286_515f007c_232"

--5098d286_515f007c_232
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Vladimir, 

your interceptor wasn't released, because it was never tracked in the first place.
It's not disposable, has no custom decommission steps, and no dependencies that requires decommission.


There's no reason for it to be tracked.


-- 
Krzysztof Kozmic


On Tuesday, 6 November 2012 at 6:59 PM, Vladimir Okhotnikov wrote:

> Hi
> 
> I have a following failing test in an empty project with Windsor 3.1 from NuGet:
> 
> [Test]
> public void TransientInterceptor()
> {
> var interceptorCreated = false;
> var interceptorReleased = false;
> 
> var c = new DefaultKernel();
> c.ComponentCreated += (model, instance) =>
> {
> if (model.Implementation == typeof(AnInterceptor))
> {
> interceptorCreated = true;
> }
> };
> c.ComponentDestroyed += (model, instance) =>
> {
> if (model.Implementation == typeof(AnInterceptor))
> {
> interceptorReleased = true;
> }
> };
> 
> c.Register(
> Component.For<AComponent>().LifeStyle.Transient,
> Component.For<AnInterceptor>().LifeStyle.Transient);
> 
> var component = c.Resolve<AComponent>();
> c.ReleaseComponent(component);
> 
> Assert.IsTrue(interceptorCreated);
> Assert.IsTrue(interceptorReleased);
> }
> 
> public class AnInterceptor : IInterceptor
> {
> public void Intercept(IInvocation invocation)
> {
> invocation.Proceed();
> }
> }
> 
> [Interceptor(typeof(AnInterceptor))]
> public class AComponent
> {
> public virtual void Intercepted() 
> {
> }
> }
> 
> The test fails on the very last line, i.e. ComponentDestroyed for the interceptor is never being called. Is it a bug or am I missing something?
> 
> Regards,
> Vladimir Okhotnikov
> 
> -- 
> You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
> To post to this group, send email to castle-project-users@googlegroups.com (mailto:castle-project-users@googlegroups.com).
> To unsubscribe from this group, send email to castle-project-users+unsubscribe@googlegroups.com (mailto:castle-project-users+unsubscribe@googlegroups.com).
> For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
> 
> 



--5098d286_515f007c_232
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline


                <div>Vladimir,
                </div><div><br></div><div>your interceptor wasn't release=
d, because it was never tracked in the first place.</div><div>It's not di=
sposable, has no custom decommission steps, and no dependencies that requ=
ires decommission.</div><div><br></div><div><br></div><div>There's no rea=
son for it to be tracked.<br><br></div>
                <div><div><br></div><div>--&nbsp;</div><div>Krzysztof Koz=
mic<br></div><div><br></div></div>
                =20
                <p style=3D=22color: =23A0A0A8;=22>On Tuesday, 6 November=
 2012 at 6:59 PM, Vladimir Okhotnikov wrote:</p>
                <blockquote type=3D=22cite=22 style=3D=22border-left-styl=
e:solid;border-width:1px;margin-left:0px;padding-left:10px;=22>
                    <span><div><div><div>Hi</div><div><br></div><div>I ha=
ve a following failing test in an empty project with Windsor 3.1 from NuG=
et:</div><div><br></div><div>        =5BTest=5D</div><div>        public =
void TransientInterceptor()</div><div>        =7B</div><div>            v=
ar interceptorCreated =3D false;</div><div>            var interceptorRel=
eased =3D false;</div><div><br></div><div>            var c =3D new Defau=
ltKernel();</div><div>            c.ComponentCreated +=3D (model, instanc=
e) =3D&gt;</div><div>            =7B</div><div>                if (model.=
Implementation =3D=3D typeof(AnInterceptor))</div><div>                =7B=
</div><div>                    interceptorCreated =3D true;</div><div>   =
             =7D</div><div>            =7D;</div><div>            c.Compo=
nentDestroyed +=3D (model, instance) =3D&gt;</div><div>            =7B</d=
iv><div>                if (model.Implementation =3D=3D typeof(AnIntercep=
tor))</div><div>                =7B</div><div>                    interce=
ptorReleased =3D true;</div><div>                =7D</div><div>          =
  =7D;</div><div><br></div><div>            c.Register(</div><div>       =
         Component.=46or&lt;AComponent&gt;().LifeStyle.Transient,</div><d=
iv>                Component.=46or&lt;AnInterceptor&gt;().LifeStyle.Trans=
ient);</div><div><br></div><div>            var component =3D c.Resolve&l=
t;AComponent&gt;();</div><div>            c.ReleaseComponent(component);<=
/div><div><br></div><div>            Assert.IsTrue(interceptorCreated);</=
div><div>            Assert.IsTrue(interceptorReleased);</div><div>      =
  =7D</div><div><br></div><div>        public class AnInterceptor : IInte=
rceptor</div><div>        =7B</div><div>            public void Intercept=
(IInvocation invocation)</div><div>            =7B</div><div>            =
    invocation.Proceed();</div><div>            =7D</div><div>        =7D=
</div><div><br></div><div>        =5BInterceptor(typeof(AnInterceptor))=5D=
</div><div>        public class AComponent</div><div>        =7B</div><di=
v>            public virtual void Intercepted() </div><div>            =7B=
</div><div>            =7D</div><div>        =7D</div><div><br></div><div=
>The test fails on the very last line, i.e. ComponentDestroyed for the in=
terceptor is never being called. Is it a bug or am I missing something=3F=
</div><div><br></div><div>Regards,</div><div>Vladimir Okhotnikov</div><di=
v><br></div><div>-- </div><div>You received this message because you are =
subscribed to the Google Groups =22Castle Project Users=22 group.</div><d=
iv>To post to this group, send email to <a href=3D=22mailto:castle-projec=
t-users=40googlegroups.com=22>castle-project-users=40googlegroups.com</a>=
.</div><div>To unsubscribe from this group, send email to <a href=3D=22ma=
ilto:castle-project-users+unsubscribe=40googlegroups.com=22>castle-projec=
t-users+unsubscribe=40googlegroups.com</a>.</div><div>=46or more options,=
 visit this group at <a href=3D=22http://groups.google.com/group/castle-p=
roject-users=3Fhl=3Den=22>http://groups.google.com/group/castle-project-u=
sers=3Fhl=3Den</a>.</div></div></div></span>
                =20
                =20
                =20
                =20
                </blockquote>
                =20
                <div>
                    <br>
                </div>
            
--5098d286_515f007c_232--