Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [improvement] JAVA-1241: Upgrade Netty to 4.1.x.
- [improvement] JAVA-1287: Add CDC to TableOptionsMetadata and Schema Builder.
- [improvement] JAVA-1392: Reduce lock contention in RPTokenFactory.
- [improvement] JAVA-1328: Provide compatibility with Guava 20.

Merged from 3.1.x branch:

Expand Down
4 changes: 2 additions & 2 deletions driver-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<_include>-osgi.bnd</_include>
<Import-Package>
<!-- JNR does not provide OSGi bundles, so exclude it; the driver can live without it -->
<![CDATA[com.google.common*;version="[${guava.version},20)",!jnr.*,*]]></Import-Package>
<![CDATA[com.google.common*;version="[16.0.1,21)",!jnr.*,*]]></Import-Package>
</instructions>
<supportedProjectTypes>
<supportedProjectType>jar</supportedProjectType>
Expand All @@ -224,7 +224,7 @@
JNR does not provide OSGi bundles, so exclude it; the driver can live without it
Explicitly import javax.security.cert because it's required by Netty, but Netty has been explicitly excluded
-->
<![CDATA[com.google.common.*;version="[${guava.version},20)",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
<![CDATA[com.google.common.*;version="[16.0.1,21)",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
<Private-Package>com.datastax.shaded.*</Private-Package>
</instructions>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.datastax.driver.core;

import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.reflect.TypeToken;

import java.math.BigDecimal;
Expand Down Expand Up @@ -280,7 +280,7 @@ public boolean equals(Object o) {

Object thisValue = this.codecFor(i).deserialize(this.values[i], this.protocolVersion);
Object thatValue = that.codecFor(i).deserialize(that.values[i], that.protocolVersion);
if (!Objects.equal(thisValue, thatValue))
if (!MoreObjects.equal(thisValue, thatValue))
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.datastax.driver.core;

import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.reflect.TypeToken;

import java.math.BigDecimal;
Expand Down Expand Up @@ -575,7 +575,7 @@ public boolean equals(Object o) {

Object thisValue = this.codecFor(i).deserialize(this.values[i], this.protocolVersion);
Object thatValue = that.codecFor(i).deserialize(that.values[i], that.protocolVersion);
if (!Objects.equal(thisValue, thatValue))
if (!MoreObjects.equal(thisValue, thatValue))
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.datastax.driver.core;

import com.datastax.driver.core.utils.Bytes;
import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
Expand Down Expand Up @@ -376,11 +376,11 @@ public boolean equals(Object other) {
AggregateMetadata that = (AggregateMetadata) other;
return this.keyspace.getName().equals(that.keyspace.getName()) &&
this.argumentTypes.equals(that.argumentTypes) &&
Objects.equal(this.finalFuncFullName, that.finalFuncFullName) &&
MoreObjects.equal(this.finalFuncFullName, that.finalFuncFullName) &&
// Note: this might be a problem if a custom codec has been registered for the initCond's type, with a target Java type that
// does not properly implement equals. We don't have any control over this, at worst this would lead to spurious change
// notifications.
Objects.equal(this.initCond, that.initCond) &&
MoreObjects.equal(this.initCond, that.initCond) &&
this.returnType.equals(that.returnType) &&
this.stateFuncFullName.equals(that.stateFuncFullName) &&
this.stateType.equals(that.stateType);
Expand All @@ -390,7 +390,6 @@ public boolean equals(Object other) {

@Override
public int hashCode() {
return Objects.hashCode(this.keyspace.getName(), this.argumentTypes,
this.finalFuncFullName, this.initCond, this.returnType, this.stateFuncFullName, this.stateType);
return MoreObjects.hashCode(this.keyspace.getName(), this.argumentTypes, this.finalFuncFullName, this.initCond, this.returnType, this.stateFuncFullName, this.stateType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* additional {@link #force} method that can be used to expedite the shutdown
* process (see below).
* <p/>
* Note that this class implements <a href="http://code.google.com/p/guava-libraries/">Guava</a>'s {@code
* Note that this class implements <a href="http://github.com/google/guava/">Guava</a>'s {@code
* ListenableFuture} and can so be used with Guava's future utilities.
*/
public abstract class CloseFuture extends AbstractFuture<Void> {
Expand Down
12 changes: 6 additions & 6 deletions driver-core/src/main/java/com/datastax/driver/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public class Cluster implements Closeable {
private static final Logger logger = LoggerFactory.getLogger(Cluster.class);

static {
// Perform sanity checks to inform user of possible environment misconfiguration.
SanityChecks.check();
// Force initialization to fail fast if there is an issue detecting the version
GuavaCompatibility.init();
}

@VisibleForTesting
Expand Down Expand Up @@ -334,15 +334,15 @@ public ListenableFuture<Session> connectAsync(final String keyspace) {
return sessionInitialized;
} else {
final String useQuery = "USE " + keyspace;
ListenableFuture<ResultSet> keyspaceSet = Futures.transform(sessionInitialized, new AsyncFunction<Session, ResultSet>() {
ListenableFuture<ResultSet> keyspaceSet = GuavaCompatibility.INSTANCE.transformAsync(sessionInitialized, new AsyncFunction<Session, ResultSet>() {
@Override
public ListenableFuture<ResultSet> apply(Session session) throws Exception {
return session.executeAsync(useQuery);
}
});
ListenableFuture<ResultSet> withErrorHandling = Futures.withFallback(keyspaceSet, new FutureFallback<ResultSet>() {
ListenableFuture<ResultSet> withErrorHandling = GuavaCompatibility.INSTANCE.withFallback(keyspaceSet, new AsyncFunction<Throwable, ResultSet>() {
@Override
public ListenableFuture<ResultSet> create(Throwable t) throws Exception {
public ListenableFuture<ResultSet> apply(Throwable t) throws Exception {
session.closeAsync();
if (t instanceof SyntaxError) {
// Give a more explicit message, because it's probably caused by a bad keyspace name
Expand Down Expand Up @@ -2373,7 +2373,7 @@ public void run() {
rs.getExecutionInfo().setSchemaInAgreement(finalSchemaInAgreement);
future.setResult(rs);
}
}, MoreExecutors.sameThreadExecutor());
}, GuavaCompatibility.INSTANCE.sameThreadExecutor());

} catch (Exception e) {
logger.warn("Error while waiting for schema agreement", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.datastax.driver.core;

import com.datastax.driver.core.exceptions.CodecNotFoundException;
import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.cache.*;
import com.google.common.reflect.TypeToken;
import com.google.common.util.concurrent.UncheckedExecutionException;
Expand Down Expand Up @@ -216,12 +216,12 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass())
return false;
CacheKey cacheKey = (CacheKey) o;
return Objects.equal(cqlType, cacheKey.cqlType) && Objects.equal(javaType, cacheKey.javaType);
return MoreObjects.equal(cqlType, cacheKey.cqlType) && MoreObjects.equal(javaType, cacheKey.javaType);
}

@Override
public int hashCode() {
return Objects.hashCode(cqlType, javaType);
return MoreObjects.hashCode(cqlType, javaType);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.datastax.driver.core;

import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;

import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -116,7 +116,7 @@ public boolean equals(Object other) {

@Override
public int hashCode() {
return Objects.hashCode(name, isStatic, type);
return MoreObjects.hashCode(name, isStatic, type);
}

@Override
Expand Down
22 changes: 11 additions & 11 deletions driver-core/src/main/java/com/datastax/driver/core/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.datastax.driver.core.Responses.Result.SetKeyspace;
import com.datastax.driver.core.exceptions.*;
import com.datastax.driver.core.utils.MoreFutures;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
import com.google.common.util.concurrent.*;
Expand Down Expand Up @@ -179,13 +179,13 @@ public void operationComplete(ChannelFuture future) throws Exception {

Executor initExecutor = factory.manager.configuration.getPoolingOptions().getInitializationExecutor();

ListenableFuture<Void> initializeTransportFuture = Futures.transform(channelReadyFuture,
ListenableFuture<Void> initializeTransportFuture = GuavaCompatibility.INSTANCE.transformAsync(channelReadyFuture,
onChannelReady(protocolVersion, initExecutor), initExecutor);

// Fallback on initializeTransportFuture so we can properly propagate specific exceptions.
ListenableFuture<Void> initFuture = Futures.withFallback(initializeTransportFuture, new FutureFallback<Void>() {
ListenableFuture<Void> initFuture = GuavaCompatibility.INSTANCE.withFallback(initializeTransportFuture, new AsyncFunction<Throwable, Void>() {
@Override
public ListenableFuture<Void> create(Throwable t) throws Exception {
public ListenableFuture<Void> apply(Throwable t) throws Exception {
SettableFuture<Void> future = SettableFuture.create();
// Make sure the connection gets properly closed.
if (t instanceof ClusterNameMismatchException || t instanceof UnsupportedProtocolVersionException) {
Expand Down Expand Up @@ -233,7 +233,7 @@ private AsyncFunction<Void, Void> onChannelReady(final ProtocolVersion protocolV
public ListenableFuture<Void> apply(Void input) throws Exception {
ProtocolOptions.Compression compression = factory.configuration.getProtocolOptions().getCompression();
Future startupResponseFuture = write(new Requests.Startup(compression));
return Futures.transform(startupResponseFuture,
return GuavaCompatibility.INSTANCE.transformAsync(startupResponseFuture,
onStartupResponse(protocolVersion, initExecutor), initExecutor);
}
};
Expand Down Expand Up @@ -297,7 +297,7 @@ private ListenableFuture<Void> checkClusterName(ProtocolVersion protocolVersion,
DefaultResultSetFuture clusterNameFuture = new DefaultResultSetFuture(null, protocolVersion, new Requests.Query("select cluster_name from system.local"));
try {
write(clusterNameFuture);
return Futures.transform(clusterNameFuture,
return GuavaCompatibility.INSTANCE.transformAsync(clusterNameFuture,
new AsyncFunction<ResultSet, Void>() {
@Override
public ListenableFuture<Void> apply(ResultSet rs) throws Exception {
Expand All @@ -323,7 +323,7 @@ private ListenableFuture<Void> authenticateV1(Authenticator authenticator, final
Requests.Credentials creds = new Requests.Credentials(((ProtocolV1Authenticator) authenticator).getCredentials());
try {
Future authResponseFuture = write(creds);
return Futures.transform(authResponseFuture,
return GuavaCompatibility.INSTANCE.transformAsync(authResponseFuture,
new AsyncFunction<Message.Response, Void>() {
@Override
public ListenableFuture<Void> apply(Message.Response authResponse) throws Exception {
Expand All @@ -350,7 +350,7 @@ private ListenableFuture<Void> authenticateV2(final Authenticator authenticator,

try {
Future authResponseFuture = write(new Requests.AuthResponse(initialResponse));
return Futures.transform(authResponseFuture, onV2AuthResponse(authenticator, protocolVersion, executor), executor);
return GuavaCompatibility.INSTANCE.transformAsync(authResponseFuture, onV2AuthResponse(authenticator, protocolVersion, executor), executor);
} catch (Exception e) {
return Futures.immediateFailedFuture(e);
}
Expand All @@ -376,7 +376,7 @@ public ListenableFuture<Void> apply(Message.Response authResponse) throws Except
// Otherwise, send the challenge response back to the server
logger.trace("{} Sending Auth response to challenge", this);
Future nextResponseFuture = write(new Requests.AuthResponse(responseToServer));
return Futures.transform(nextResponseFuture, onV2AuthResponse(authenticator, protocolVersion, executor), executor);
return GuavaCompatibility.INSTANCE.transformAsync(nextResponseFuture, onV2AuthResponse(authenticator, protocolVersion, executor), executor);
}
case ERROR:
// This is not very nice, but we're trying to identify if we
Expand Down Expand Up @@ -471,7 +471,7 @@ void setKeyspace(String keyspace) throws ConnectionException {
if (keyspace == null)
return;

if (Objects.equal(keyspace(), keyspace))
if (MoreObjects.equal(keyspace(), keyspace))
return;

try {
Expand All @@ -497,7 +497,7 @@ void setKeyspace(String keyspace) throws ConnectionException {

ListenableFuture<Connection> setKeyspaceAsync(final String keyspace) throws ConnectionException, BusyConnectionException {
SetKeyspaceAttempt existingAttempt = targetKeyspace.get();
if (Objects.equal(existingAttempt.keyspace, keyspace))
if (MoreObjects.equal(existingAttempt.keyspace, keyspace))
return existingAttempt.future;

final SettableFuture<Connection> ksFuture = SettableFuture.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package com.datastax.driver.core;

import com.datastax.driver.core.exceptions.*;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.util.concurrent.ListenableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -519,7 +519,7 @@ private static void updateInfo(Host host, Row row, Cluster.Manager cluster, bool
}

private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) {
if (Objects.equal(host.getDatacenter(), datacenter) && Objects.equal(host.getRack(), rack))
if (MoreObjects.equal(host.getDatacenter(), datacenter) && MoreObjects.equal(host.getRack(), rack))
return;

// If the dc/rack information changes for an existing node, we need to update the load balancing policy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.datastax.driver.core;

import com.datastax.driver.core.exceptions.DriverInternalError;
import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -662,7 +662,7 @@ public List<DataType> getTypeArguments() {

@Override
public final int hashCode() {
return Objects.hashCode(name, typeArguments);
return MoreObjects.hashCode(name, typeArguments);
}

@Override
Expand Down Expand Up @@ -740,7 +740,7 @@ public String getCustomTypeClassName() {

@Override
public final int hashCode() {
return Objects.hashCode(name, customClassName);
return MoreObjects.hashCode(name, customClassName);
}

@Override
Expand All @@ -749,7 +749,7 @@ public final boolean equals(Object o) {
return false;

DataType.CustomType d = (DataType.CustomType) o;
return name == d.name && Objects.equal(customClassName, d.customClassName);
return name == d.name && MoreObjects.equal(customClassName, d.customClassName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.datastax.driver.core;

import com.google.common.base.Objects;
import com.datastax.driver.core.utils.MoreObjects;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -321,6 +321,6 @@ public boolean equals(Object other) {

@Override
public int hashCode() {
return Objects.hashCode(keyspace.getName(), arguments, body, calledOnNullInput, language, returnType);
return MoreObjects.hashCode(keyspace.getName(), arguments, body, calledOnNullInput, language, returnType);
}
}
Loading