Title: [2268] branches/v-1.4.x: Fix: SqlTimestampConverter throws IllegalArgumentException instead of ConversionException on fromString().
Revision
2268
Author
joehni
Date
2014-03-03 12:20:42 -0600 (Mon, 03 Mar 2014)

Log Message

Fix: SqlTimestampConverter throws IllegalArgumentException instead of ConversionException on fromString().

Modified Paths

Diff

Modified: branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/SqlTimestampConverter.java (2267 => 2268)


--- branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/SqlTimestampConverter.java	2014-02-26 22:33:28 UTC (rev 2267)
+++ branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/SqlTimestampConverter.java	2014-03-03 18:20:42 UTC (rev 2268)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003, 2004 Joe Walnes.
- * Copyright (C) 2006, 2007, 2012 XStream Committers.
+ * Copyright (C) 2006, 2007, 2012, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -11,6 +11,7 @@
  */
 package com.thoughtworks.xstream.converters.extended;
 
+import com.thoughtworks.xstream.converters.ConversionException;
 import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
 import com.thoughtworks.xstream.core.util.ThreadSafeSimpleDateFormat;
 
@@ -52,7 +53,7 @@
     public Object fromString(String str) {
         int idx = str.lastIndexOf('.');
         if (idx < 0 || str.length() - idx < 2 || str.length() - idx > 10) {
-            throw new IllegalArgumentException(
+            throw new ConversionException(
                 "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]");
         }
         try {
@@ -63,9 +64,12 @@
             }
             timestamp.setNanos(Integer.parseInt(buffer.toString()));
             return timestamp;
+        } catch (NumberFormatException e) {
+            throw new ConversionException(
+                "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]", e);
         } catch (ParseException e) {
-            throw new IllegalArgumentException(
-                "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]");
+            throw new ConversionException(
+                "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]", e);
         }
     }
 

Modified: branches/v-1.4.x/xstream-distribution/src/content/changes.html (2267 => 2268)


--- branches/v-1.4.x/xstream-distribution/src/content/changes.html	2014-02-26 22:33:28 UTC (rev 2267)
+++ branches/v-1.4.x/xstream-distribution/src/content/changes.html	2014-03-03 18:20:42 UTC (rev 2268)
@@ -37,6 +37,7 @@
     <ul>
     	<li>Fix: DateConverter ignores provided locale.</li>
     	<li>Fix: WeakCache.entrySet().iterator().next.setValue(value) returns the reference instead of the old value.</li>
+    	<li>Fix: SqlTimestampConverter throws IllegalArgumentException instead of ConversionException on fromString().</li>
     </ul>
 
     <h2>API changes</h2>

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to