[JIRA] Created: (CC-1056) Bug in CVS version detection

"Grant Wagner (JIRA)" <[email protected]> Tue, 7 Aug 2012 10:00:13 -0500 (CDT)
Newsgroups gmane.comp.java.cruise-control.devel
Message-ID <1931262851.1344351613370.JavaMail.jira@chidmzhosting02.thoughtworks.com>
Bug in CVS version detection
----------------------------

                 Key: CC-1056
                 URL: http://jira.public.thoughtworks.org/browse/CC-1056
             Project: CruiseControl
          Issue Type: Bug
          Components: Core Application
    Affects Versions: 2.8.4
         Environment: Ubuntu 11.04 server
Cruisecontrol 2.8.4, running as a service
CVS 1.12.13-MirDebian-8
            Reporter: Grant Wagner
            Priority: Major


Symptom: 
   After moving to a new cvs server, cruise control would no longer trigger builds using the cvs change tracker. A look in the log showed the following two errors (edited to remove proprietary information) every time cvs was checked for updates:
  ERROR ConcurrentVersionsSystem - problem identifying cvs server. Assuming output is of 'old' type
  ERROR ConcurrentVersionsSystem - Error parsing cvs LOG for date and time java.text.ParseException: Unparseable date:

First, the output of cvs version, which I believe is common for copies of cvs installed by package managers.

$ cvs -d :pserver:user:pass@chicvsns/usr/local/cvs/Netsort version
Client: Concurrent Versions System (CVS) 1.12.13-MirDebian-8 (client/server)
Server: Concurrent Versions System (CVS) 1.12.13-MirDebian-8 (client/server)

I was able to track down the issue to net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem.isCvsNewOutputFormat(); 

This method takes the version string, delimited by spaces to be 1.12.13-MirDebian-8. It then tokenizes using the '.' as a delimiter, and checks the second and third token as an integer. An exception is thrown at line 454 trying to parse the string "13-MirDebian-8". 

I found this patch, donated by "Lynx" on the cvs irc channel. I haven't personally tested it.

Index: ConcurrentVersionsSystem.java
===================================================================
--- ConcurrentVersionsSystem.java	(revision 4615)
+++ ConcurrentVersionsSystem.java	(working copy)
@@ -436,7 +436,14 @@
             LOG.warn("cvs server version number couldn't be parsed from " + line);
             return null;
         }
-        version = line.substring(nameEnd + 2, verEnd);
+	int verDash = line.indexOf("-", nameEnd + 2);
+	if (verDash < nameEnd + 2 || verEnd < verDash) {
+		/* version 1.11.1p1 (Client/Server) */
+		version = line.substring(nameEnd + 2, verEnd);
+	} else {
+		/* version 1.12.13-something (Client/Server) */
+		version = line.substring(nameEnd + 2, verDash);
+	}
 
         return new Version(name, version);
     }

#End Patch

I personally would have this rewritten to delimit off of any non integer field, just to be sure.

Hope this helps, thanks.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.public.thoughtworks.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/