kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 6a3c428100912fad29ee2dbf3cf1073978b2ba0fa33d18fa61d05c4509813ea7 |
|---|---|
| Author | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-18 18:24 +01:00 |
| Committer | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-18 18:24 +01:00 |
| Parents | 6ec239cc86dc |
2 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | - [bug] Fix potential thread leaks when shutting down Metrics (JAVA-232) |
| 12 | 12 | - [bug] Fix potential NPE in HostConnectionPool (JAVA-231) |
| 13 | 13 | - [bug] Make sure connections are returned to the right pools (JAVA-255) |
| 14 | +- [bug] Use date string in query build to work-around CASSANDRA-6718 (JAVA-264) | |
| 14 | 15 | |
| 15 | 16 | |
| 16 | 17 | 1.0.5: |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Utils.java +13 −1
| @@ -19,6 +19,7 @@ | ||
| 19 | 19 | import java.nio.ByteBuffer; |
| 20 | 20 | import java.util.*; |
| 21 | 21 | import java.util.regex.Pattern; |
| 22 | +import java.text.SimpleDateFormat; | |
| 22 | 23 | |
| 23 | 24 | import org.apache.cassandra.utils.ByteBufferUtil; |
| 24 | 25 | |
| @@ -27,6 +28,16 @@ | ||
| 27 | 28 | |
| 28 | 29 | private static final Pattern cnamePattern = Pattern.compile("\\w+(?:\\[.+\\])?"); |
| 29 | 30 | |
| 31 | + // We currently format date as strings instead of simply longs due to JAVA-264. We could change | |
| 32 | + // that back to longs (which is cheaper) once C* 1.2 gets eol (since only pre-1.2.16 versions are | |
| 33 | + // affected). | |
| 34 | + private static final ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat>() { | |
| 35 | + @Override | |
| 36 | + protected SimpleDateFormat initialValue() { | |
| 37 | + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); | |
| 38 | + } | |
| 39 | + }; | |
| 40 | + | |
| 30 | 41 | static StringBuilder joinAndAppend(StringBuilder sb, String separator, List<? extends Appendeable> values) { |
| 31 | 42 | for (int i = 0; i < values.size(); i++) { |
| 32 | 43 | if (i > 0) |
| @@ -100,6 +111,7 @@ | ||
| 100 | 111 | } |
| 101 | 112 | } |
| 102 | 113 | |
| 114 | + | |
| 103 | 115 | private static boolean appendValueIfLiteral(Object value, StringBuilder sb) { |
| 104 | 116 | if (value instanceof Number || value instanceof UUID || value instanceof Boolean) { |
| 105 | 117 | sb.append(value); |
| @@ -108,7 +120,7 @@ | ||
| 108 | 120 | sb.append("'").append(((InetAddress)value).getHostAddress()).append("'"); |
| 109 | 121 | return true; |
| 110 | 122 | } else if (value instanceof Date) { |
| 111 | - sb.append(((Date)value).getTime()); | |
| 123 | + sb.append("'").append(dateFormat.get().format((Date)value)).append("'"); | |
| 112 | 124 | return true; |
| 113 | 125 | } else if (value instanceof ByteBuffer) { |
| 114 | 126 | sb.append("0x"); |