Lightstreamer / Lightstreamer-lib-client-dotnet

Lightstreamer .Net Standard Client SDK
Apache License 2.0
3 stars 1 forks source link

BaseChannelPoolHandler - Specified cast is not valid. #3

Open kosomgua opened 1 year ago

kosomgua commented 1 year ago

Channel in BaseChannelPoolHandler throwing errors when ChannelReleased or ChannelAcquired called, cause in this code you trying to cast from IAttribute<IdleStateTimer> to IdleStateTimer type.

        public virtual void ChannelReleased(IChannel channel)
        {
            IdleStateTimer idls = (IdleStateTimer)channel.GetAttribute(IDLE_KEY);
            idls.setIdle();
        }

        public virtual void ChannelAcquired(IChannel channel)
        {
            IdleStateTimer idls = (IdleStateTimer)channel.GetAttribute(IDLE_KEY);
            idls.setActive();
        }

Should be changed to

        public virtual void ChannelReleased(IChannel channel)
        {
            IdleStateTimer idls = channel.GetAttribute(IDLE_KEY).Get();
            idls.setIdle();
        }

        public virtual void ChannelAcquired(IChannel channel)
        {
            IdleStateTimer idls = channel.GetAttribute(IDLE_KEY).Get();
            idls.setActive();
        }