Bug 37636 - cvschangelog cant parse date + throws NullPointerExeption
Summary: cvschangelog cant parse date + throws NullPointerExeption
Status: RESOLVED DUPLICATE of bug 30962
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.6.5
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-25 10:56 UTC by Andreas
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas 2005-11-25 10:56:19 UTC
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;
     }
 
     /**
Comment 1 Stephane Bailliez 2005-11-25 11:24:27 UTC

*** This bug has been marked as a duplicate of 30962 ***