You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jk...@apache.org on 2009/01/31 17:14:58 UTC

svn commit: r739572 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

Author: jkf
Date: Sat Jan 31 16:14:58 2009
New Revision: 739572

URL: http://svn.apache.org/viewvc?rev=739572&view=rev
Log:
Fixed some obvious errors. (Formatter class is not thread safe, equals from string to another object).

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java?rev=739572&r1=739571&r2=739572&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java Sat Jan 31 16:14:58 2009
@@ -93,6 +93,10 @@
      * are HH:mm:ss */
     private static final long GRANULARITY_MINUTE = 60000L;
 
+    /** Date formatter used in logging, note not thread safe! */
+    private static final SimpleDateFormat TIMESTAMP_LOGGING_SDF =
+        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
     /** Default port for FTP */
     public static final int DEFAULT_FTP_PORT = 21;
 
@@ -1486,7 +1490,7 @@
      * @see org.apache.commons.net.ftp.FTPClientConfig
      */
     public void setServerLanguageCodeConfig(LanguageCode serverLanguageCode) {
-        if (serverLanguageCode != null && !serverLanguageCode.equals("")) {
+        if (serverLanguageCode != null && !"".equals(serverLanguageCode.getValue())) {
             this.serverLanguageCodeConfig = serverLanguageCode;
             configurationHasBeenSet();
         }
@@ -1598,7 +1602,7 @@
      * @param timestampGranularity The timestampGranularity to set.
      */
     public void setTimestampGranularity(Granularity timestampGranularity) {
-        if (null == timestampGranularity || "".equals(timestampGranularity)) {
+        if (null == timestampGranularity || "".equals(timestampGranularity.getValue())) {
             return;
         }
         this.timestampGranularity = timestampGranularity;
@@ -1993,9 +1997,6 @@
         return null;
     }
 
-    private static final SimpleDateFormat TIMESTAMP_LOGGING_SDF =
-        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
     /**
      * Checks to see if the remote file is current as compared with the local
      * file. Returns true if the target file is up to date.
@@ -2035,18 +2036,25 @@
         long adjustedRemoteTimestamp =
             remoteTimestamp + this.timeDiffMillis + this.granularityMillis;
 
-        StringBuffer msg = new StringBuffer("   [")
-            .append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp)))
-            .append("] local");
+        StringBuffer msg;
+        synchronized(TIMESTAMP_LOGGING_SDF) {
+            msg = new StringBuffer("   [")
+                .append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp)))
+                .append("] local");
+        }
         log(msg.toString(), Project.MSG_VERBOSE);
 
-        msg = new StringBuffer("   [")
-            .append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp)))
-            .append("] remote");
+        synchronized(TIMESTAMP_LOGGING_SDF) {
+            msg = new StringBuffer("   [")
+                .append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp)))
+                .append("] remote");
+        }
         if (remoteTimestamp != adjustedRemoteTimestamp) {
-            msg.append(" - (raw: ")
-                .append(TIMESTAMP_LOGGING_SDF.format(new Date(remoteTimestamp)))
-                .append(")");
+            synchronized(TIMESTAMP_LOGGING_SDF) {
+                msg.append(" - (raw: ")
+                    .append(TIMESTAMP_LOGGING_SDF.format(new Date(remoteTimestamp)))
+                    .append(")");
+            }
         }
         log(msg.toString(), Project.MSG_VERBOSE);
 
@@ -2620,7 +2628,6 @@
          * @return the list of valid Granularity values
          */
         public String[] getValues() {
-            // TODO Auto-generated method stub
             return VALID_GRANULARITIES;
         }
         /**