You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by Nicklas Nordborg <ni...@compunet.se> on 2008/05/28 20:42:56 UTC
The User.getAuthorities(Class clazz) method has a flaw
I think this method has a flaw in it's signature. It is impossible to
call this method with any other class object than the Authority.class.
For example if I try:
Authority[] auth = user.getAuthorities(WritePermission.class);
I get the following compile error (cleaned up a bit):
[javac] BaseUserManager.java:118: cannot find symbol
[javac] symbol : method getAuthorities(Class<WritePermission>)
[javac] location: class net.sf.basedb.clients.ftp.BaseUser
[javac] user.getAuthorities(WritePermission.class);
[javac] ^
A workaround is to do:
Class c = WritePermission.class;
Authority[] auth = user.getAuthorities(c);
I think the proper solution is to change the method signature to:
Authority[] getAuthorities(Class<? extends Authority> clazz);
This would allow any subclass of the Authority class to be used as a
parameter.
Just a final note. It is no big deal for me. I am not going to call this
method in my code and it seems like it is not called anywhere internally
in the FTP Server code either. It was just something I noticed while
implementing the User interface and trying to test my implementation of it.
/Nicklas
Re: The User.getAuthorities(Class clazz) method has a flaw
Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Wed, May 28, 2008 at 8:42 PM, Nicklas Nordborg <ni...@compunet.se> wrote:
> I think this method has a flaw in it's signature. It is impossible to call
> this method with any other class object than the Authority.class. For
> example if I try:
>
> Authority[] auth = user.getAuthorities(WritePermission.class);
Yeah, that makes that method pretty useless :-)
I just commited a fix for this, thanks for reporting!
/niklas
Re: The User.getAuthorities(Class clazz) method has a
flaw
Posted by Nicklas Nordborg <ni...@thep.lu.se>.
Nicklas Nordborg wrote:
> I think the proper solution is to change the method signature to:
>
> Authority[] getAuthorities(Class<? extends Authority> clazz);
Or maybe:
<A extends Authority> A[] getAuthorities(Class<A> clazz);
/Nicklas