Do I have to remove the attribute when connection is closed.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Do I have to remove the attribute when connection is closed.

LongkerDandy
Hi

I've a TCP server, which using Conenction and Attribute to save user's auth information.
Like this:


private static final Attribute<Integer> ATTR_AUTH = Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute("auth");
public static void setAuthState(Connection connection, int authState) {
        ATTR_AUTH.set(connection, authState);
    }


And I saw some strange logs, seems something when a client connected, it already have the attribute.
I can't locate the problem, and I wondered do I need to remove the attributes when a connection is closed.

Regards
LongkerDandy
Reply | Threaded
Open this post in threaded view
|

Re: Do I have to remove the attribute when connection is closed.

oleksiys
Administrator
Hi,

no, you don't have to remove attributes they have to be GC'ed (if there
are no other references).

WBR,
Alexey.

On 04.11.14 01:18, LongkerDandy wrote:

> Hi
>
> I've a TCP server, which using Conenction and Attribute to save user's
> auth information.
> Like this:
>
>
> private static final Attribute<Integer> ATTR_AUTH =
> Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute("auth");
> public static void setAuthState(Connection connection, int authState) {
>         ATTR_AUTH.set(connection, authState);
>     }
>
>
> And I saw some strange logs, seems something when a client connected,
> it already have the attribute.
> I can't locate the problem, and I wondered do I need to remove the
> attributes when a connection is closed.
>
> Regards
> LongkerDandy