Elffuss BraidHub

kikocis/java-driver public

Add Clirr plugin + fix backward compatibility issues.
Changesetda8137a35958d2352028a84f03f4ff489be04ebd4c1ef4b1d840a09692ae3571
Authorolim7t <omichallat+github@gmail.com> · 2014-10-09 12:12 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-10-09 12:13 +02:00
Parentsd9f56f5d0e64

Browse the files at this changeset

12 files changed

added clirr-ignores.xml +64 −0
@@ -0,0 +1,64 @@
1+<!--
2+ Clirr is a tool that checks Java libraries for binary and source compatibility with older releases.
3+
4+ This file lists known (and accepted) differences with the reference version specified in pom.xml.
5+
6+ To update this file:
7+ * run `mvn clirr:clirr` at the root directory
8+ * check the reports in `<module>/target/site/clirr-report.html`
9+ * add new differences if needed. Difference types are explained at http://mojo.codehaus.org/clirr-maven-plugin/examples/ignored-differences.html
10+-->
11+<differences>
12+ <difference>
13+ <differenceType>7006</differenceType> <!-- return type changed -->
14+ <className>com/datastax/driver/core/BatchStatement</className>
15+ <method>com.datastax.driver.core.Statement setSerialConsistencyLevel(com.datastax.driver.core.ConsistencyLevel)</method>
16+ <to>com.datastax.driver.core.BatchStatement</to>
17+ <justification>A covariant return makes the API more fluent. It's unlikely that any client has extended this class</justification>
18+ </difference>
19+
20+ <difference>
21+ <differenceType>6002</differenceType> <!-- no longer a compile-time constant -->
22+ <className>com/datastax/driver/core/ProtocolOptions</className>
23+ <field>NEWEST_SUPPORTED_PROTOCOL_VERSION</field>
24+ <justification>It calls an enum's method that is known to have a constant result</justification>
25+ </difference>
26+
27+ <difference>
28+ <differenceType>7004</differenceType> <!-- argument count changed -->
29+ <className>com/datastax/driver/core/exceptions/UnsupportedFeatureException</className>
30+ <method>UnsupportedFeatureException(java.lang.String)</method>
31+ <justification>A client has no reason to call this constructor</justification>
32+ </difference>
33+
34+ <difference>
35+ <differenceType>7012</differenceType> <!-- method added to interface -->
36+ <className>com/datastax/driver/core/ResultSet</className>
37+ <method>boolean wasApplied()</method>
38+ <justification>This interface is not meant to be extended by clients</justification>
39+ </difference>
40+
41+ <difference>
42+ <differenceType>7013</differenceType> <!-- abstract method added -->
43+ <className>com/datastax/driver/core/RegularStatement</className>
44+ <method>java.nio.ByteBuffer[] getValues(com.datastax.driver.core.ProtocolVersion)</method>
45+ <justification>Indeed a breaking change, but extending this class from a client should be rarely needed</justification>
46+ </difference>
47+
48+ <difference>
49+ <differenceType>7005</differenceType> <!-- argument type changed -->
50+ <className>com/datastax/driver/core/SimpleStatement</className>
51+ <method>java.nio.ByteBuffer[] getValues(int)</method>
52+ <to>java.nio.ByteBuffer[] getValues(com.datastax.driver.core.ProtocolVersion)</to>
53+ <justification>A backward compatible version has been added to the parent class RegularStatement</justification>
54+ </difference>
55+
56+ <difference>
57+ <differenceType>7005</differenceType> <!-- argument type changed -->
58+ <className>com/datastax/driver/core/querybuilder/*</className>
59+ <method>java.nio.ByteBuffer[] getValues(int)</method>
60+ <to>java.nio.ByteBuffer[] getValues(com.datastax.driver.core.ProtocolVersion)</to>
61+ <justification>A backward compatible version has been added to the parent class RegularStatement</justification>
62+ </difference>
63+
64+</differences>
modified driver-core/src/main/java/com/datastax/driver/core/AbstractGettableData.java +10 −0
@@ -37,6 +37,16 @@
3737 super(protocolVersion);
3838 }
3939
40+ /**
41+ * @throws IllegalArgumentException if {@code protocolVersion} does not correspond to any known version.
42+ *
43+ * @deprecated This constructor is provided for backward compatibility, use {@link #AbstractGettableData(ProtocolVersion)} instead.
44+ */
45+ @Deprecated
46+ protected AbstractGettableData(int protocolVersion) {
47+ this(ProtocolVersion.fromInt(protocolVersion));
48+ }
49+
4050 /**
4151 * Returns the index corresponding to a given name.
4252 *
modified driver-core/src/main/java/com/datastax/driver/core/ProtocolOptions.java +32 −1
@@ -62,6 +62,14 @@
6262 */
6363 public static final int DEFAULT_PORT = 9042;
6464
65+ /**
66+ * The newest version of the protocol that this version of the driver support.
67+ *
68+ * @deprecated This is provided for backward compatibility; use {@link ProtocolVersion#NEWEST_SUPPORTED} instead.
69+ */
70+ @Deprecated
71+ public static final int NEWEST_SUPPORTED_PROTOCOL_VERSION = ProtocolVersion.NEWEST_SUPPORTED.toInt();
72+
6573 private volatile Cluster.Manager manager;
6674
6775 private final int port;
@@ -112,6 +120,19 @@
112120 this.authProvider = authProvider;
113121 }
114122
123+ /**
124+ * @throws IllegalArgumentException if {@code protocolVersion} does not correspond to any known version.
125+ *
126+ * @deprecated This is provided for backward compatibility; use {@link #ProtocolOptions(int, ProtocolVersion, SSLOptions, AuthProvider))} instead.
127+ */
128+ @Deprecated
129+ public ProtocolOptions(int port, int protocolVersion, SSLOptions sslOptions, AuthProvider authProvider) {
130+ this.port = port;
131+ this.initialProtocolVersion = ProtocolVersion.fromInt(protocolVersion);
132+ this.sslOptions = sslOptions;
133+ this.authProvider = authProvider;
134+ }
135+
115136 void register(Cluster.Manager manager) {
116137 this.manager = manager;
117138 }
@@ -134,10 +155,20 @@
134155 * Cluster instance is connected, this is guaranteed to return a non-null value). Note that
135156 * nodes that do not support this protocol version will be ignored.
136157 */
137- public ProtocolVersion getProtocolVersion() {
158+ public ProtocolVersion getProtocolVersionEnum() {
138159 return manager.connectionFactory.protocolVersion;
139160 }
140161
162+ /**
163+ * The protocol version used by the Cluster instance, as a number.
164+ *
165+ * @deprecated This is provided for backward compatibility, use {@link #getProtocolVersionEnum()} instead.
166+ */
167+ @Deprecated
168+ public int getProtocolVersion() {
169+ return getProtocolVersionEnum().toInt();
170+ }
171+
141172 /**
142173 * Returns the compression used by the protocol.
143174 * <p>
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +4 −4
@@ -133,7 +133,7 @@
133133 switch (rm.kind) {
134134 case PREPARED:
135135 Responses.Result.Prepared pmsg = (Responses.Result.Prepared)rm;
136- PreparedStatement stmt = DefaultPreparedStatement.fromMessage(pmsg, cluster.getMetadata(), cluster.getConfiguration().getProtocolOptions().getProtocolVersion(), query, poolsState.keyspace);
136+ PreparedStatement stmt = DefaultPreparedStatement.fromMessage(pmsg, cluster.getMetadata(), cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum(), query, poolsState.keyspace);
137137 stmt = cluster.manager.addPrepared(stmt);
138138 try {
139139 // All Sessions are connected to the same nodes so it's enough to prepare only the nodes of this session.
@@ -197,7 +197,7 @@
197197 return true;
198198
199199 HostConnectionPool newPool = HostConnectionPool.newInstance(host, distance, SessionManager.this,
200- cluster.getConfiguration().getProtocolOptions().getProtocolVersion());
200+ cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum());
201201 HostConnectionPool previous = pools.put(host, newPool);
202202 if (previous == null) {
203203 logger.debug("Added connection pool for {}", host);
@@ -237,7 +237,7 @@
237237 return false;
238238
239239 HostConnectionPool newPool = HostConnectionPool.newInstance(host, distance, SessionManager.this,
240- cluster.getConfiguration().getProtocolOptions().getProtocolVersion());
240+ cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum());
241241 pools.put(host, newPool);
242242
243243 // If we raced with a session shutdown, ensure that the pool will be closed.
@@ -493,7 +493,7 @@
493493 if (statement.isTracing())
494494 msg.setTracingRequested();
495495
496- DefaultResultSetFuture future = new DefaultResultSetFuture(this, configuration().getProtocolOptions().getProtocolVersion(), msg);
496+ DefaultResultSetFuture future = new DefaultResultSetFuture(this, configuration().getProtocolOptions().getProtocolVersionEnum(), msg);
497497 execute(future, statement);
498498 return future;
499499 }
modified driver-core/src/main/java/com/datastax/driver/core/policies/Policies.java +20 −0
@@ -52,6 +52,26 @@
5252 this(loadBalancingPolicy, reconnectionPolicy, retryPolicy, DEFAULT_ADDRESS_TRANSLATER, defaultTimestampGenerator());
5353 }
5454
55+ /**
56+ * Creates a new {@code Policies} object using the provided policies.
57+ *
58+ * @param loadBalancingPolicy the load balancing policy to use.
59+ * @param reconnectionPolicy the reconnection policy to use.
60+ * @param retryPolicy the retry policy to use.
61+ * @param addressTranslater the address translater to use.
62+ */
63+ public Policies(LoadBalancingPolicy loadBalancingPolicy,
64+ ReconnectionPolicy reconnectionPolicy,
65+ RetryPolicy retryPolicy,
66+ AddressTranslater addressTranslater) {
67+ // NB: this constructor is provided for backward compatibility with 2.1.0
68+ this.loadBalancingPolicy = loadBalancingPolicy;
69+ this.reconnectionPolicy = reconnectionPolicy;
70+ this.retryPolicy = retryPolicy;
71+ this.addressTranslater = addressTranslater;
72+ this.timestampGenerator = defaultTimestampGenerator();
73+ }
74+
5575 /**
5676 * Creates a new {@code Policies} object using the provided policies.
5777 *
modified driver-core/src/test/java/com/datastax/driver/core/BatchStatementTest.java +2 −2
@@ -71,7 +71,7 @@
7171
7272 } catch (UnsupportedFeatureException e) {
7373 // This is expected when testing the protocol v1
74- if (cluster.getConfiguration().getProtocolOptions().getProtocolVersion() != ProtocolVersion.V1)
74+ if (cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum() != ProtocolVersion.V1)
7575 throw e;
7676 } catch (Throwable t) {
7777 errorOut();
@@ -106,7 +106,7 @@
106106
107107 } catch (UnsupportedFeatureException e) {
108108 // This is expected when testing the protocol v1
109- if (cluster.getConfiguration().getProtocolOptions().getProtocolVersion() != ProtocolVersion.V1)
109+ if (cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum() != ProtocolVersion.V1)
110110 throw e;
111111 } catch (Throwable t) {
112112 errorOut();
modified driver-core/src/test/java/com/datastax/driver/core/FetchingTest.java +1 −1
@@ -61,7 +61,7 @@
6161
6262 } catch (UnsupportedFeatureException e) {
6363 // This is expected when testing the protocol v1
64- if (cluster.getConfiguration().getProtocolOptions().getProtocolVersion() != ProtocolVersion.V1)
64+ if (cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum() != ProtocolVersion.V1)
6565 throw e;
6666 } catch (Throwable e) {
6767 errorOut();
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +1 −1
@@ -407,7 +407,7 @@
407407 assertEquals("bar", all.get(2).getString("v"));
408408 } catch (UnsupportedFeatureException e) {
409409 // This is expected when testing the protocol v1
410- if (cluster.getConfiguration().getProtocolOptions().getProtocolVersion() != ProtocolVersion.V1)
410+ if (cluster.getConfiguration().getProtocolOptions().getProtocolVersionEnum() != ProtocolVersion.V1)
411411 throw e;
412412 }
413413 }
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +1 −1
@@ -372,7 +372,7 @@
372372
373373 public static int numberOfLocalCoreConnections(Cluster cluster) {
374374 Configuration configuration = cluster.getConfiguration();
375- ProtocolVersion protocolVersion = configuration.getProtocolOptions().getProtocolVersion();
375+ ProtocolVersion protocolVersion = configuration.getProtocolOptions().getProtocolVersionEnum();
376376 return (protocolVersion.compareTo(ProtocolVersion.V3) < 0)
377377 ? configuration.getPoolingOptions().getCoreConnectionsPerHost(HostDistance.LOCAL)
378378 : 1;
modified driver-mapping/src/main/java/com/datastax/driver/mapping/Mapper.java +1 −1
@@ -61,7 +61,7 @@
6161 KeyspaceMetadata keyspace = session().getCluster().getMetadata().getKeyspace(mapper.getKeyspace());
6262 this.tableMetadata = keyspace == null ? null : keyspace.getTable(Metadata.quote(mapper.getTable()));
6363
64- this.protocolVersion = manager.getSession().getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
64+ this.protocolVersion = manager.getSession().getCluster().getConfiguration().getProtocolOptions().getProtocolVersionEnum();
6565 this.mapOneFunction = new Function<ResultSet, T>() {
6666 public T apply(ResultSet rs) {
6767 return Mapper.this.map(rs).one();
modified driver-mapping/src/main/java/com/datastax/driver/mapping/MethodMapper.java +1 −1
@@ -123,7 +123,7 @@
123123
124124 BoundStatement bs = statement.bind();
125125
126- ProtocolVersion protocolVersion = session.getCluster().getConfiguration().getProtocolOptions().getProtocolVersion();
126+ ProtocolVersion protocolVersion = session.getCluster().getConfiguration().getProtocolOptions().getProtocolVersionEnum();
127127 for (int i = 0; i < args.length; i++) {
128128 paramMappers[i].setValue(bs, args[i], protocolVersion);
129129 }
modified pom.xml +17 −0
@@ -108,6 +108,23 @@
108108 <tagNameFormat>@{project.version}</tagNameFormat>
109109 </configuration>
110110 </plugin>
111+ <plugin>
112+ <groupId>org.codehaus.mojo</groupId>
113+ <artifactId>clirr-maven-plugin</artifactId>
114+ <version>2.6.1</version>
115+ <configuration>
116+ <comparisonVersion>2.1.0</comparisonVersion>
117+ <ignoredDifferencesFile>../clirr-ignores.xml</ignoredDifferencesFile>
118+ <excludes>
119+ <!-- Package-private, internal classes -->
120+ <exclude>com/datastax/driver/core/Frame$*</exclude>
121+ <exclude>com/datastax/driver/core/ProtocolEvent$*</exclude>
122+ <exclude>com/datastax/driver/core/Message$*</exclude>
123+ <exclude>com/datastax/driver/core/Requests$*</exclude>
124+ <exclude>com/datastax/driver/core/Responses$*</exclude>
125+ </excludes>
126+ </configuration>
127+ </plugin>
111128 </plugins>
112129 </build>
113130