avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver SiteCommandHandler.java
Date Thu, 10 Oct 2002 16:01:01 GMT
rana_b      2002/10/10 09:01:01

  Modified:    ftpserver/src/java/org/apache/avalon/ftpserver
                        SiteCommandHandler.java
  Log:
  resolved date format threading issue
  
  Revision  Changes    Path
  1.5       +14 -5     jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/SiteCommandHandler.java
  
  Index: SiteCommandHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/SiteCommandHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SiteCommandHandler.java	20 May 2002 10:20:17 -0000	1.4
  +++ SiteCommandHandler.java	10 Oct 2002 16:01:01 -0000	1.5
  @@ -29,8 +29,14 @@
   public
   class SiteCommandHandler {
   
  -    protected static final SimpleDateFormat DATE_FMT = new SimpleDateFormat("MM/dd HH:mm:ss");
  -    protected static final Class[] INPUT_SIG = new Class[] {String[].class, FtpRequest.class};
  +    // as SimpleDateFormat is not thread-safe we have to use ThreadLocal
  +    private final static ThreadLocal DATE_FMT = new ThreadLocal() {
  +        protected Object initialValue() {
  +            return new SimpleDateFormat("MM/dd HH:mm:ss"); 
  +        }
  +    };
  +    
  +    protected final static Class[] INPUT_SIG = new Class[] {String[].class, FtpRequest.class};
   
       private FtpConfig mConfig;
       private FtpUser mUser;
  @@ -95,7 +101,7 @@
   
   
       /**
  -     * Has permission.
  +     * Has permission
        */
       private boolean hasPermission(String args[]) {
           UserManagerInterface userManager = mConfig.getUserManager();
  @@ -376,10 +382,12 @@
               if (!user.hasLoggedIn()) {
                   continue;
               }
  +            
  +            SimpleDateFormat fmt = (SimpleDateFormat)DATE_FMT.get();
               sb.append( StringUtils.pad(user.getName(), ' ', true, 16) );
               sb.append( StringUtils.pad(user.getClientAddress().getHostAddress(), ' ', true,
16) );
  -            sb.append( StringUtils.pad(DATE_FMT.format(new Date(user.getLoginTime())),
' ', true, 16) );
  -            sb.append( StringUtils.pad(DATE_FMT.format(new Date(user.getLastAccessTime())),
' ', true, 16) );
  +            sb.append( StringUtils.pad(fmt.format(new Date(user.getLoginTime())), ' ',
true, 16) );
  +            sb.append( StringUtils.pad(fmt.format(new Date(user.getLastAccessTime())),
' ', true, 16) );
               sb.append('\n');
           }
           sb.append('\n');
  @@ -387,3 +395,4 @@
       }
   
   }
  +
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message