[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Possible bad (incorrect) JavaHL test inserted into 1.5.x

From: Mark Phippard <markphip_at_gmail.com>
Date: Sat, 24 May 2008 19:41:46 -0400

On Sat, May 24, 2008 at 7:26 PM, Mark Phippard <markphip_at_gmail.com> wrote:
> On Sat, May 24, 2008 at 7:21 PM, Blair Zajac <blair_at_orcaware.com> wrote:
>
>>> Since the revprops are coming in a Map, it makes sense that they are
>>> consistently all the same type of object, in which case it needs to be
>>> a String. I also agree with Hyrum that it makes sense to do as much
>>> logic in Java as we can.
>>
>> Not when it adds to the overhead of understanding what the code does.
>
> What are you referring to? The revprop Map? I think Hyrum did a
> pretty good job explaining why it should be the way it is. I also do
> not think it makes sense for every object in the Map to be a string,
> except for the svn:date which users are supposed to know is some other
> kind of object. It also precludes us from ever using generics.
>
> Are Subversion dates always in UTC? That is what I think the problem is.

I think this is the right change (assuming the dates we get are in UTC):

1) When parsing the date, we add the TimeZone to the string we are
parsing and to the parser so that it knows the timezone was UTC.

2) When we create the Calendar object we create it with UTC timezone.

3) Adjusted the test to the new value (14,400 seconds less or -04:00).

Index: subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java
===================================================================
--- subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java (revision
31430)
+++ subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java (working
copy)
@@ -88,7 +88,7 @@
         try
         {
             logDate = new LogDate(goodDate);
- Assert.assertEquals(1191481252134992L, logDate.getTimeMicros());
+ Assert.assertEquals(1191466852134992L, logDate.getTimeMicros());
         } catch (ParseException e) {
             Assert.fail("Failed to parse date " + goodDate);
         }
Index: subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java
===================================================================
--- subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java (revision
31430)
+++ subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java (working
copy)
@@ -23,6 +23,7 @@
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.TimeZone;

 /**
  * Holds date for a log message. This class maintains
@@ -34,7 +35,8 @@
 {
     private static final long serialVersionUID = 1L;
     private static final DateFormat formatter = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss.SSS");
+ "yyyy-MM-dd'T'HH:mm:ss.SSS z");
+ private static final TimeZone UTC = TimeZone.getTimeZone("UTC");

     private final long timeMicros;
     private final String cachedString;
@@ -45,9 +47,9 @@
         if (datestr == null || datestr.length() < 27) {
                 throw new ParseException("String is not a valid Subversion date", 0);
         }
- Date date = formatter.parse(datestr.substring(0, 23));
+ Date date = formatter.parse(datestr.substring(0, 23) + " UTC");
         this.cachedString = datestr;
- cachedDate = Calendar.getInstance();
+ cachedDate = Calendar.getInstance(UTC);
         cachedDate.setTime(date);
         timeMicros = cachedDate.getTimeInMillis() * 1000
                         + Integer.parseInt(datestr.substring(23, 26));

-- 
Thanks
Mark Phippard
http://markphip.blogspot.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-05-25 01:41:59 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.