ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37636] New: - cvschangelog cant parse date + throws NullPointerExeption
Date Fri, 25 Nov 2005 09:56:19 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37636>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37636

           Summary: cvschangelog cant parse date + throws
                    NullPointerExeption
           Product: Ant
           Version: 1.6.5
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: av@tonbeller.com


In CVS 1.12.12 the command "cvs log" uses "-" as date separator (e.g.
2005-10-02). Other CVS versions use "/" as separator (e.g. 2005/10/02). Ant
ChangeLogParser does not understand the "-" format and throws a
NullPointerException in java.util.Date#after().

The following patch fixes the problem:


--- ChangeLogParser.java.1	2005-06-02 15:20:00.000000000 +0200
+++ ChangeLogParser.java.2	2005-11-25 10:21:56.000000000 +0100
@@ -36,12 +36,15 @@
     private static final int GET_PREVIOUS_REV = 5;
 
     /** input format for dates read in from cvs log */
-    private static final SimpleDateFormat c_inputDate
-        = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+    private static final SimpleDateFormat[] c_inputDates = {
+        new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"),
+        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
+    };
 
     static {
         TimeZone utc = TimeZone.getTimeZone("UTC");
-        c_inputDate.setTimeZone(utc);
+        for (int i = 0; i < c_inputDates.length; i++)
+            c_inputDates[i].setTimeZone(utc);
     }
 
     //The following is data used while processing stdout of CVS command
@@ -215,13 +218,14 @@
      * @return the date object or null if unknown date format
      */
     private Date parseDate(final String date) {
+      for (int i = 0; i < c_inputDates.length; i++) {
         try {
-            return c_inputDate.parse(date);
+            return c_inputDates[i].parse(date);
         } catch (ParseException e) {
-            //final String message = REZ.getString( "changelog.bat-date.error",
date );
-            //getContext().error( message );
-            return null;
+          // ignore
         }
+      }
+      return null;
     }
 
     /**

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message