Elffuss BraidHub

kikocis/java-driver public

Merge pull request #636 from datastax/java1136

JAVA-1136: Enable JDK signature check in module driver-extras.
Changeset49e1ebe6c2254369543d9a50965e3c2b2b37571584a360cba1c782f7319a14fd
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2016-04-20 18:07 +02:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2016-04-20 18:07 +02:00
Parents6e44dad32a41, b401801f3d44

Browse the files at this changeset

10 files changed

modified changelog/README.md +1 −0
@@ -9,6 +9,7 @@
99 - [bug] JAVA-1074: Fix documentation around default timestamp generator.
1010 - [improvement] JAVA-1109: Document SSLOptions changes in upgrade guide.
1111 - [improvement] JAVA-1065: Add method to create token from partition key values.
12+- [improvement] JAVA-1136: Enable JDK signature check in module driver-extras.
1213
1314 Merged from 2.1 branch:
1415
modified driver-extras/pom.xml +33 −12
@@ -142,18 +142,39 @@
142142 <plugin>
143143 <groupId>org.codehaus.mojo</groupId>
144144 <artifactId>animal-sniffer-maven-plugin</artifactId>
145- <configuration>
146- <!--
147- There is no support for JDK 8 yet, see
148- https://github.com/mojohaus/animal-sniffer/issues/1
149- -->
150- <skip>true</skip>
151- <signature>
152- <groupId>org.codehaus.mojo.signature</groupId>
153- <artifactId>java18</artifactId>
154- <version>1.0</version>
155- </signature>
156- </configuration>
145+ <executions>
146+ <execution>
147+ <id>check</id>
148+ <phase>process-classes</phase>
149+ <goals>
150+ <goal>check</goal>
151+ </goals>
152+ <configuration>
153+ <signature>
154+ <groupId>org.codehaus.mojo.signature</groupId>
155+ <artifactId>java16</artifactId>
156+ <version>1.0</version>
157+ </signature>
158+ <annotations>
159+ <annotation>com.datastax.driver.extras.codecs.jdk8.IgnoreJDK6Requirement</annotation>
160+ </annotations>
161+ </configuration>
162+ </execution>
163+ <execution>
164+ <id>check-jdk8</id>
165+ <phase>process-classes</phase>
166+ <goals>
167+ <goal>check</goal>
168+ </goals>
169+ <configuration>
170+ <signature>
171+ <groupId>org.codehaus.mojo.signature</groupId>
172+ <artifactId>java18</artifactId>
173+ <version>1.0</version>
174+ </signature>
175+ </configuration>
176+ </execution>
177+ </executions>
157178 </plugin>
158179
159180 <plugin>
added driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/IgnoreJDK6Requirement.java +25 −0
@@ -0,0 +1,25 @@
1+/*
2+ * Copyright (C) 2012-2015 DataStax Inc.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package com.datastax.driver.extras.codecs.jdk8;
17+
18+/**
19+ * Annotation used to mark classes in this package as
20+ * excluded from JDK signature check performed
21+ * by <a href="http://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/check-mojo.html">animal-sniffer</a>
22+ * Maven plugin as they require JDK 8 and not the usual JDK 6.
23+ */
24+@interface IgnoreJDK6Requirement {
25+}
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/InstantCodec.java +25 −30
@@ -21,90 +21,85 @@
2121 import com.datastax.driver.core.exceptions.InvalidTypeException;
2222
2323 import java.nio.ByteBuffer;
24-import java.time.Instant;
25-import java.time.format.DateTimeFormatter;
26-import java.time.format.DateTimeFormatterBuilder;
27-import java.time.format.DateTimeParseException;
2824
2925 import static com.datastax.driver.core.ParseUtils.*;
3026 import static java.lang.Long.parseLong;
31-import static java.time.Instant.ofEpochMilli;
32-import static java.time.ZoneOffset.UTC;
33-import static java.time.temporal.ChronoField.*;
3427
3528 /**
36- * {@link TypeCodec} that maps {@link Instant} to CQL {@code timestamp}
29+ * {@link TypeCodec} that maps {@link java.time.Instant} to CQL {@code timestamp}
3730 * allowing the setting and retrieval of {@code timestamp}
38- * columns as {@link Instant} instances.
31+ * columns as {@link java.time.Instant} instances.
3932 * <p/>
4033 * Since C* <code>timestamp</code> columns do not preserve timezones
4134 * any attached timezone information will be lost.
4235 * <p/>
43- * <strong>IMPORTANT</strong>: this codec's {@link #format(Instant) format} method formats
36+ * <strong>IMPORTANT</strong>: this codec's {@link #format(java.time.Instant) format} method formats
4437 * timestamps using an ISO-8601 format that includes milliseconds.
4538 * <strong>This format is incompatible with Cassandra versions < 2.0.9.</strong>
4639 *
4740 * @see ZonedDateTimeCodec
4841 * @see <a href="https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps">'Working with timestamps' section of CQL specification</a>
4942 */
50-public class InstantCodec extends TypeCodec<Instant> {
43+@IgnoreJDK6Requirement
44+@SuppressWarnings("Since15")
45+public class InstantCodec extends TypeCodec<java.time.Instant> {
5146
5247 public static final InstantCodec instance = new InstantCodec();
5348
5449 /**
55- * A {@link DateTimeFormatter} that parses (most) of
50+ * A {@link java.time.format.DateTimeFormatter} that parses (most) of
5651 * the ISO formats accepted in CQL.
5752 */
58- private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder()
53+ private static final java.time.format.DateTimeFormatter PARSER = new java.time.format.DateTimeFormatterBuilder()
5954 .parseCaseSensitive()
6055 .parseStrict()
61- .append(DateTimeFormatter.ISO_LOCAL_DATE)
56+ .append(java.time.format.DateTimeFormatter.ISO_LOCAL_DATE)
6257 .optionalStart()
6358 .appendLiteral('T')
64- .appendValue(HOUR_OF_DAY, 2)
59+ .appendValue(java.time.temporal.ChronoField.HOUR_OF_DAY, 2)
6560 .appendLiteral(':')
66- .appendValue(MINUTE_OF_HOUR, 2)
61+ .appendValue(java.time.temporal.ChronoField.MINUTE_OF_HOUR, 2)
6762 .optionalEnd()
6863 .optionalStart()
6964 .appendLiteral(':')
70- .appendValue(SECOND_OF_MINUTE, 2)
65+ .appendValue(java.time.temporal.ChronoField.SECOND_OF_MINUTE, 2)
7166 .optionalEnd()
7267 .optionalStart()
73- .appendFraction(NANO_OF_SECOND, 0, 9, true)
68+ .appendFraction(java.time.temporal.ChronoField.NANO_OF_SECOND, 0, 9, true)
7469 .optionalEnd()
7570 .optionalStart()
7671 .appendZoneId()
7772 .optionalEnd()
7873 .toFormatter()
79- .withZone(UTC);
74+ .withZone(java.time.ZoneOffset.UTC);
8075
81- private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
82- .withZone(UTC);
76+ private static final java.time.format.DateTimeFormatter FORMATTER = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
77+ .withZone(java.time.ZoneOffset.UTC);
8378
8479
8580 private InstantCodec() {
86- super(DataType.timestamp(), Instant.class);
81+ super(DataType.timestamp(), java.time.Instant.class);
8782 }
8883
8984 @Override
90- public ByteBuffer serialize(Instant value, ProtocolVersion protocolVersion) {
85+ public ByteBuffer serialize(java.time.Instant value, ProtocolVersion protocolVersion) {
9186 return value == null ? null : bigint().serializeNoBoxing(value.toEpochMilli(), protocolVersion);
9287 }
9388
9489 @Override
95- public Instant deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) {
96- return bytes == null || bytes.remaining() == 0 ? null : ofEpochMilli(bigint().deserializeNoBoxing(bytes, protocolVersion));
90+ public java.time.Instant deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) {
91+ return bytes == null || bytes.remaining() == 0 ? null : java.time.Instant.ofEpochMilli(bigint().deserializeNoBoxing(bytes, protocolVersion));
9792 }
9893
9994 @Override
100- public String format(Instant value) {
95+ public String format(java.time.Instant value) {
10196 if (value == null)
10297 return "NULL";
10398 return quote(FORMATTER.format(value));
10499 }
105100
106101 @Override
107- public Instant parse(String value) {
102+ public java.time.Instant parse(String value) {
108103 if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
109104 return null;
110105 // strip enclosing single quotes, if any
@@ -112,14 +107,14 @@
112107 value = unquote(value);
113108 if (isLongLiteral(value)) {
114109 try {
115- return ofEpochMilli(parseLong(value));
110+ return java.time.Instant.ofEpochMilli(parseLong(value));
116111 } catch (NumberFormatException e) {
117112 throw new InvalidTypeException(String.format("Cannot parse timestamp value from \"%s\"", value));
118113 }
119114 }
120115 try {
121- return Instant.from(PARSER.parse(value));
122- } catch (DateTimeParseException e) {
116+ return java.time.Instant.from(PARSER.parse(value));
117+ } catch (java.time.format.DateTimeParseException e) {
123118 throw new InvalidTypeException(String.format("Cannot parse timestamp value from \"%s\"", value));
124119 }
125120 }
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/LocalDateCodec.java +12 −13
@@ -21,39 +21,38 @@
2121 import com.datastax.driver.core.exceptions.InvalidTypeException;
2222
2323 import java.nio.ByteBuffer;
24-import java.time.LocalDate;
25-import java.time.temporal.ChronoUnit;
2624
2725 import static com.datastax.driver.core.CodecUtils.*;
2826 import static com.datastax.driver.core.ParseUtils.*;
2927 import static java.lang.Long.parseLong;
30-import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE;
3128
3229 /**
3330 * {@link TypeCodec} that maps
3431 * {@link java.time.LocalDate} to CQL {@code date}.
3532 */
36-public class LocalDateCodec extends TypeCodec<LocalDate> {
33+@IgnoreJDK6Requirement
34+@SuppressWarnings("Since15")
35+public class LocalDateCodec extends TypeCodec<java.time.LocalDate> {
3736
3837 public static final LocalDateCodec instance = new LocalDateCodec();
3938
40- private static final LocalDate EPOCH = LocalDate.of(1970, 1, 1);
39+ private static final java.time.LocalDate EPOCH = java.time.LocalDate.of(1970, 1, 1);
4140
4241 private LocalDateCodec() {
43- super(DataType.date(), LocalDate.class);
42+ super(DataType.date(), java.time.LocalDate.class);
4443 }
4544
4645 @Override
47- public ByteBuffer serialize(LocalDate value, ProtocolVersion protocolVersion) {
46+ public ByteBuffer serialize(java.time.LocalDate value, ProtocolVersion protocolVersion) {
4847 if (value == null)
4948 return null;
50- long days = ChronoUnit.DAYS.between(EPOCH, value);
49+ long days = java.time.temporal.ChronoUnit.DAYS.between(EPOCH, value);
5150 int unsigned = fromSignedToUnsignedInt((int) days);
5251 return cint().serializeNoBoxing(unsigned, protocolVersion);
5352 }
5453
5554 @Override
56- public LocalDate deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) {
55+ public java.time.LocalDate deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) {
5756 if (bytes == null || bytes.remaining() == 0)
5857 return null;
5958 int unsigned = cint().deserializeNoBoxing(bytes, protocolVersion);
@@ -62,14 +61,14 @@
6261 }
6362
6463 @Override
65- public String format(LocalDate value) {
64+ public String format(java.time.LocalDate value) {
6665 if (value == null)
6766 return "NULL";
68- return quote(ISO_LOCAL_DATE.format(value));
67+ return quote(java.time.format.DateTimeFormatter.ISO_LOCAL_DATE.format(value));
6968 }
7069
7170 @Override
72- public LocalDate parse(String value) {
71+ public java.time.LocalDate parse(String value) {
7372 if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
7473 return null;
7574
@@ -95,7 +94,7 @@
9594 }
9695
9796 try {
98- return LocalDate.parse(value, ISO_LOCAL_DATE);
97+ return java.time.LocalDate.parse(value, java.time.format.DateTimeFormatter.ISO_LOCAL_DATE);
9998 } catch (RuntimeException e) {
10099 throw new InvalidTypeException(String.format("Cannot parse date value from \"%s\"", value));
101100 }
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/LocalTimeCodec.java +13 −13
@@ -22,48 +22,48 @@
2222 import com.datastax.driver.core.exceptions.InvalidTypeException;
2323
2424 import java.nio.ByteBuffer;
25-import java.time.LocalTime;
26-import java.time.format.DateTimeFormatter;
2725
2826 import static com.datastax.driver.core.ParseUtils.quote;
2927
3028 /**
31- * {@link TypeCodec} that maps {@link LocalTime} to CQL {@code time} (long representing nanoseconds since midnight).
29+ * {@link TypeCodec} that maps {@link java.time.LocalTime} to CQL {@code time} (long representing nanoseconds since midnight).
3230 */
33-public class LocalTimeCodec extends TypeCodec<LocalTime> {
31+@IgnoreJDK6Requirement
32+@SuppressWarnings("Since15")
33+public class LocalTimeCodec extends TypeCodec<java.time.LocalTime> {
3434
3535 public static final LocalTimeCodec instance = new LocalTimeCodec();
3636
37- private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
37+ private static final java.time.format.DateTimeFormatter FORMATTER = java.time.format.DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
3838
3939 private LocalTimeCodec() {
40- super(DataType.time(), LocalTime.class);
40+ super(DataType.time(), java.time.LocalTime.class);
4141 }
4242
4343 @Override
44- public ByteBuffer serialize(LocalTime value, ProtocolVersion protocolVersion) throws InvalidTypeException {
44+ public ByteBuffer serialize(java.time.LocalTime value, ProtocolVersion protocolVersion) throws InvalidTypeException {
4545 if (value == null)
4646 return null;
4747 return bigint().serializeNoBoxing(value.toNanoOfDay(), protocolVersion);
4848 }
4949
5050 @Override
51- public LocalTime deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
51+ public java.time.LocalTime deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
5252 if (bytes == null || bytes.remaining() == 0)
5353 return null;
5454 long nanosOfDay = bigint().deserializeNoBoxing(bytes, protocolVersion);
55- return LocalTime.ofNanoOfDay(nanosOfDay);
55+ return java.time.LocalTime.ofNanoOfDay(nanosOfDay);
5656 }
5757
5858 @Override
59- public String format(LocalTime value) {
59+ public String format(java.time.LocalTime value) {
6060 if (value == null)
6161 return "NULL";
6262 return quote(FORMATTER.format(value));
6363 }
6464
6565 @Override
66- public LocalTime parse(String value) {
66+ public java.time.LocalTime parse(String value) {
6767 if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
6868 return null;
6969
@@ -79,11 +79,11 @@
7979 } catch (NumberFormatException e) {
8080 throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e);
8181 }
82- return LocalTime.ofNanoOfDay(nanosOfDay);
82+ return java.time.LocalTime.ofNanoOfDay(nanosOfDay);
8383 }
8484
8585 try {
86- return LocalTime.parse(value);
86+ return java.time.LocalTime.parse(value);
8787 } catch (RuntimeException e) {
8888 throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e);
8989 }
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/OptionalCodec.java +11 −11
@@ -22,20 +22,20 @@
2222
2323 import java.util.Collection;
2424 import java.util.Map;
25-import java.util.Optional;
26-import java.util.function.Predicate;
2725
2826 /**
29- * A codec that wraps other codecs around JDK 8's {@link Optional} API.
27+ * A codec that wraps other codecs around JDK 8's {@link java.util.Optional} API.
3028 *
3129 * @param <T> The wrapped Java type
3230 */
33-public class OptionalCodec<T> extends MappingCodec<Optional<T>, T> {
31+@IgnoreJDK6Requirement
32+@SuppressWarnings({"Since15", "OptionalUsedAsFieldOrParameterType"})
33+public class OptionalCodec<T> extends MappingCodec<java.util.Optional<T>, T> {
3434
35- private final Predicate<T> isAbsent;
35+ private final java.util.function.Predicate<T> isAbsent;
3636
3737 public OptionalCodec(TypeCodec<T> codec) {
38- this(codec, new Predicate<T>() {
38+ this(codec, new java.util.function.Predicate<T>() {
3939 @Override
4040 public boolean test(T input) {
4141 return input == null
@@ -46,20 +46,20 @@
4646 });
4747 }
4848
49- public OptionalCodec(TypeCodec<T> codec, Predicate<T> isAbsent) {
49+ public OptionalCodec(TypeCodec<T> codec, java.util.function.Predicate<T> isAbsent) {
5050 // @formatter:off
51- super(codec, new TypeToken<Optional<T>>() {}.where(new TypeParameter<T>() {}, codec.getJavaType()));
51+ super(codec, new TypeToken<java.util.Optional<T>>() {}.where(new TypeParameter<T>() {}, codec.getJavaType()));
5252 // @formatter:on
5353 this.isAbsent = isAbsent;
5454 }
5555
5656 @Override
57- protected Optional<T> deserialize(T value) {
58- return isAbsent(value) ? Optional.<T>empty() : Optional.of(value);
57+ protected java.util.Optional<T> deserialize(T value) {
58+ return isAbsent(value) ? java.util.Optional.<T>empty() : java.util.Optional.of(value);
5959 }
6060
6161 @Override
62- protected T serialize(Optional<T> value) {
62+ protected T serialize(java.util.Optional<T> value) {
6363 return value.isPresent() ? value.get() : absentValue();
6464 }
6565
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/ZonedDateTimeCodec.java +25 −31
@@ -19,23 +19,15 @@
1919 import com.datastax.driver.core.exceptions.InvalidTypeException;
2020
2121 import java.nio.ByteBuffer;
22-import java.time.Instant;
23-import java.time.ZoneId;
24-import java.time.ZoneOffset;
25-import java.time.ZonedDateTime;
26-import java.time.format.DateTimeFormatter;
27-import java.time.format.DateTimeFormatterBuilder;
28-import java.time.format.DateTimeParseException;
2922 import java.util.List;
3023
3124 import static com.datastax.driver.core.ParseUtils.isLongLiteral;
3225 import static com.datastax.driver.core.ParseUtils.quote;
3326 import static com.google.common.base.Preconditions.checkArgument;
34-import static java.time.temporal.ChronoField.*;
3527
3628 /**
3729 * {@link TypeCodec} that maps
38- * {@link ZonedDateTime} to CQL {@code tuple<timestamp,varchar>},
30+ * {@link java.time.ZonedDateTime} to CQL {@code tuple<timestamp,varchar>},
3931 * providing a pattern for maintaining timezone information in
4032 * Cassandra.
4133 * <p/>
@@ -53,39 +45,41 @@
5345 *
5446 * @see <a href="https://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingtimestamps">'Working with timestamps' section of CQL specification</a>
5547 */
56-public class ZonedDateTimeCodec extends TypeCodec.AbstractTupleCodec<ZonedDateTime> {
48+@IgnoreJDK6Requirement
49+@SuppressWarnings("Since15")
50+public class ZonedDateTimeCodec extends TypeCodec.AbstractTupleCodec<java.time.ZonedDateTime> {
5751
5852 /**
59- * A {@link DateTimeFormatter} that parses (most) of
53+ * A {@link java.time.format.DateTimeFormatter} that parses (most) of
6054 * the ISO formats accepted in CQL.
6155 */
62- private static final DateTimeFormatter FORMATTER = new DateTimeFormatterBuilder()
56+ private static final java.time.format.DateTimeFormatter FORMATTER = new java.time.format.DateTimeFormatterBuilder()
6357 .parseCaseSensitive()
6458 .parseStrict()
65- .append(DateTimeFormatter.ISO_LOCAL_DATE)
59+ .append(java.time.format.DateTimeFormatter.ISO_LOCAL_DATE)
6660 .optionalStart()
6761 .appendLiteral('T')
68- .appendValue(HOUR_OF_DAY, 2)
62+ .appendValue(java.time.temporal.ChronoField.HOUR_OF_DAY, 2)
6963 .appendLiteral(':')
70- .appendValue(MINUTE_OF_HOUR, 2)
64+ .appendValue(java.time.temporal.ChronoField.MINUTE_OF_HOUR, 2)
7165 .optionalEnd()
7266 .optionalStart()
7367 .appendLiteral(':')
74- .appendValue(SECOND_OF_MINUTE, 2)
68+ .appendValue(java.time.temporal.ChronoField.SECOND_OF_MINUTE, 2)
7569 .optionalEnd()
7670 .optionalStart()
77- .appendFraction(NANO_OF_SECOND, 0, 9, true)
71+ .appendFraction(java.time.temporal.ChronoField.NANO_OF_SECOND, 0, 9, true)
7872 .optionalEnd()
7973 .optionalStart()
8074 .appendZoneOrOffsetId()
8175 .optionalEnd()
8276 .toFormatter()
83- .withZone(ZoneOffset.UTC);
77+ .withZone(java.time.ZoneOffset.UTC);
8478
85- private static final DateTimeFormatter ZONE_FORMATTER = DateTimeFormatter.ofPattern("xxx");
79+ private static final java.time.format.DateTimeFormatter ZONE_FORMATTER = java.time.format.DateTimeFormatter.ofPattern("xxx");
8680
8781 public ZonedDateTimeCodec(TupleType tupleType) {
88- super(tupleType, ZonedDateTime.class);
82+ super(tupleType, java.time.ZonedDateTime.class);
8983 List<DataType> types = tupleType.getComponentTypes();
9084 checkArgument(
9185 types.size() == 2 && types.get(0).equals(DataType.timestamp()) && types.get(1).equals(DataType.varchar()),
@@ -94,12 +88,12 @@
9488 }
9589
9690 @Override
97- protected ZonedDateTime newInstance() {
91+ protected java.time.ZonedDateTime newInstance() {
9892 return null;
9993 }
10094
10195 @Override
102- protected ByteBuffer serializeField(ZonedDateTime source, int index, ProtocolVersion protocolVersion) {
96+ protected ByteBuffer serializeField(java.time.ZonedDateTime source, int index, ProtocolVersion protocolVersion) {
10397 if (index == 0) {
10498 long millis = source.toInstant().toEpochMilli();
10599 return bigint().serializeNoBoxing(millis, protocolVersion);
@@ -111,20 +105,20 @@
111105 }
112106
113107 @Override
114- protected ZonedDateTime deserializeAndSetField(ByteBuffer input, ZonedDateTime target, int index, ProtocolVersion protocolVersion) {
108+ protected java.time.ZonedDateTime deserializeAndSetField(ByteBuffer input, java.time.ZonedDateTime target, int index, ProtocolVersion protocolVersion) {
115109 if (index == 0) {
116110 long millis = bigint().deserializeNoBoxing(input, protocolVersion);
117- return Instant.ofEpochMilli(millis).atZone(ZoneOffset.UTC);
111+ return java.time.Instant.ofEpochMilli(millis).atZone(java.time.ZoneOffset.UTC);
118112 }
119113 if (index == 1) {
120114 String zoneId = varchar().deserialize(input, protocolVersion);
121- return target.withZoneSameInstant(ZoneId.of(zoneId));
115+ return target.withZoneSameInstant(java.time.ZoneId.of(zoneId));
122116 }
123117 throw new IndexOutOfBoundsException("Tuple index out of bounds. " + index);
124118 }
125119
126120 @Override
127- protected String formatField(ZonedDateTime value, int index) {
121+ protected String formatField(java.time.ZonedDateTime value, int index) {
128122 if (index == 0) {
129123 return quote(FORMATTER.format(value));
130124 }
@@ -135,7 +129,7 @@
135129 }
136130
137131 @Override
138- protected ZonedDateTime parseAndSetField(String input, ZonedDateTime target, int index) {
132+ protected java.time.ZonedDateTime parseAndSetField(String input, java.time.ZonedDateTime target, int index) {
139133 if (index == 0) {
140134 // strip enclosing single quotes, if any
141135 if (ParseUtils.isQuoted(input))
@@ -143,20 +137,20 @@
143137 if (isLongLiteral(input)) {
144138 try {
145139 long millis = Long.parseLong(input);
146- return ZonedDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.UTC);
140+ return java.time.ZonedDateTime.ofInstant(java.time.Instant.ofEpochMilli(millis), java.time.ZoneOffset.UTC);
147141 } catch (NumberFormatException e) {
148142 throw new InvalidTypeException(String.format("Cannot parse timestamp value from \"%s\"", input));
149143 }
150144 }
151145 try {
152- return ZonedDateTime.from(FORMATTER.parse(input));
153- } catch (DateTimeParseException e) {
146+ return java.time.ZonedDateTime.from(FORMATTER.parse(input));
147+ } catch (java.time.format.DateTimeParseException e) {
154148 throw new InvalidTypeException(String.format("Cannot parse timestamp value from \"%s\"", target));
155149 }
156150 }
157151 if (index == 1) {
158152 String zoneId = varchar().parse(input);
159- return target.withZoneSameInstant(ZoneId.of(zoneId));
153+ return target.withZoneSameInstant(java.time.ZoneId.of(zoneId));
160154 }
161155 throw new IndexOutOfBoundsException("Tuple index out of bounds. " + index);
162156 }
modified driver-extras/src/main/java/com/datastax/driver/extras/codecs/jdk8/package-info.java +1 −1
@@ -18,7 +18,7 @@
1818 * This package contains a collection of convenience
1919 * {@link com.datastax.driver.core.TypeCodec TypeCodec} instances useful for
2020 * serializing between CQL types and Java 8 types, such as the ones from the
21- * {@link java.time} API and {@link java.util.Optional}.
21+ * {@code java.time} API and {@code java.util.Optional}.
2222 * <p/>
2323 * <p/>
2424 * Note that, while the driver remains globally compatible with older JDKs,
modified pom.xml +1 −1
@@ -357,7 +357,7 @@
357357 <plugin>
358358 <groupId>org.codehaus.mojo</groupId>
359359 <artifactId>animal-sniffer-maven-plugin</artifactId>
360- <version>1.14</version>
360+ <version>1.15</version>
361361 <configuration>
362362 <signature>
363363 <groupId>org.codehaus.mojo.signature</groupId>