Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replacement for AttributeKey

Tags:

netty

Attributekeys are depreciated and cause problems with my code. I looked on the netty wiki and it said I should "Use valueOf(String) instead." umm, I don't see how finding the value of a string has anything to do with attribute keys. Anyone have some explanations on this?

like image 517
idiotprogrammer Avatar asked Mar 07 '26 14:03

idiotprogrammer


1 Answers

They changed the AttributeKeys at some point. They are still there though:

The old way of creating the keys:

final static AttributeKey<Long> CHECKSUMKEY = new AttributeKey("calcchecksum");

was replaced with this:

final static AttributeKey<Long> CHECKSUMKEY = AttributeKey.valueOf("calcchecksum");
final static AttributeKey<CustomClass> COMMANDKEY = AttributeKey.valueOf("command");
final static AttributeKey<Long> FILEHANDLEKEY = AttributeKey.valueOf("filehandle");
final static AttributeKey<File> PATHKEY = AttributeKey.valueOf("destpath");

So only the constructor of AttributeKey is deprecated. You can the use them like this for example:

ctx.channel().attr(Server.PATHKEY).set(file);
File file = ctx.channel().attr(Server.PATHKEY).get();
ctx.channel().attr(Server.PATHKEY).remove();
like image 151
Moh-Aw Avatar answered Mar 10 '26 16:03

Moh-Aw