[ 
https://issues.apache.org/jira/browse/FTPSERVER-450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13798859#comment-13798859
 ] 

Aizaz AZ edited comment on FTPSERVER-450 at 10/18/13 10:11 AM:
---------------------------------------------------------------

Yes exactly what I mean is "userDataFile" is always NULL. Run this code as test 
case
{code}
PropertiesUserManagerFactory propUserManagerFactory = new 
PropertiesUserManagerFactory(); 
propUserManagerFactory.setFile(new File("ftpusers.properties")); 
propUserManagerFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor()); 
mUserManager = (PropertiesUserManager) 
propUserManagerFactory.createUserManager(); <<4>>
mFTPServerFactory.setUserManager(mUserManager); 

{code}

see the code on line <<4>> when you call constructor "userDataFile" value is 
received in constructor but the class level variable is never initialized so 
when it goes into loadFromFIile() it returns because "userDataFile" is null so 
you need to do below before you call loadFromFile().
{code}
public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
            File userDataFile, String adminName) {
        super(adminName, passwordEncryptor);
        
        this.userDataFile = userDataFile;
        
        loadFromFile(userDataFile);
    }
{code}
I hope I have cleared myself furthermore you can view the code of 
PropertiesUserManager class.



was (Author: az_):
Yes exactly what I mean is "userDataFile" is always NULL. Run this code as test 
case

PropertiesUserManagerFactory propUserManagerFactory = new 
PropertiesUserManagerFactory(); 
propUserManagerFactory.setFile(new File("ftpusers.properties")); 
propUserManagerFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor()); 
mUserManager = (PropertiesUserManager) 
propUserManagerFactory.createUserManager(); <<4>>
mFTPServerFactory.setUserManager(mUserManager); 

<Sorry I don't know how to format code>

see the code on line <<4>> when you call constructor "userDataFile" value is 
received in constructor but the class level variable is never initialized so 
when it goes into loadFromFIile() it returns because "userDataFile" is null so 
you need to do below before you call loadFromFile().

public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
            File userDataFile, String adminName) {
        super(adminName, passwordEncryptor);
        
        this.userDataFile = userDataFile;
        
        loadFromFile(userDataFile);
    }

I hope I have cleared myself furthermore you can view the code of 
PropertiesUserManager class.


> PropertiesUserManager userDataFile is always NULL. 
> ---------------------------------------------------
>
>                 Key: FTPSERVER-450
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-450
>             Project: FtpServer
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.6
>         Environment: JDK 6
> Windows 7 64 BIT
>            Reporter: Aizaz AZ
>            Priority: Blocker
>         Attachments: FTPSERVER-450.patch, PropertiesUserManager.java
>
>
> PropertiesUserManager userDataFile is always NULL. Because you didn't set  
> your class variable value equal to what you get in constructor when 
> PropertiesUserManagerFactory calls your constructor new 
> PropertiesUserManager(passwordEncryptor, userDataFile, adminName); of 
> PropertiesUserManager,just need to do below super this.userDataFile = 
> userDataFile; and issue is fixed
> PropertiesUserManagerFactory propUserManagerFactory = new 
> PropertiesUserManagerFactory();
>               propUserManagerFactory.setFile(new File("ftpusers.properties"));
>               propUserManagerFactory.setPasswordEncryptor(new 
> ClearTextPasswordEncryptor());
>               mUserManager = (PropertiesUserManager) 
> propUserManagerFactory.createUserManager();
>               mFTPServerFactory.setUserManager(mUserManager);
> Set file has no effect because factory will call your constructor 
> PropertiesUserManager(passwordEncryptor, userDataFile,
>                     adminName)
> and you didn't set this.userDataFile = userDataFile;
> complete
>   public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
>             File userDataFile, String adminName) {
>         super(adminName, passwordEncryptor);
>         
>         this.userDataFile = userDataFile;
>         
>         loadFromFile(userDataFile);
>     }
> Issue fixed



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to