This is an automated email from the ASF dual-hosted git repository.

volodymyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 7d0c927c36cc4354a14ed37bd7e4a07b928d0dd9
Author: Volodymyr Vysotskyi <[email protected]>
AuthorDate: Tue Apr 14 12:14:07 2020 +0300

    DRILL-7702: Update shaded guava
---
 .../common/concurrent/AbstractCheckedFuture.java   | 99 ++++++++++++++++++++++
 .../drill/common/concurrent/CheckedFuture.java     | 72 ++++++++++++++++
 .../drill/common/exceptions/DrillIOException.java  |  2 +-
 drill-shaded/drill-shaded-guava/pom.xml            |  5 +-
 .../org/apache/drill/exec/rpc/user/UserClient.java |  4 +-
 exec/jdbc-all/pom.xml                              |  2 +
 .../org/apache/drill/exec/rpc/DrillRpcFuture.java  | 11 +--
 .../apache/drill/exec/rpc/DrillRpcFutureImpl.java  | 15 ++--
 .../apache/drill/exec/rpc/RpcCheckedFuture.java    |  6 +-
 .../org/apache/drill/exec/rpc/RpcException.java    | 11 ++-
 pom.xml                                            |  2 +-
 11 files changed, 201 insertions(+), 28 deletions(-)

diff --git 
a/common/src/main/java/org/apache/drill/common/concurrent/AbstractCheckedFuture.java
 
b/common/src/main/java/org/apache/drill/common/concurrent/AbstractCheckedFuture.java
new file mode 100644
index 0000000..eafa055
--- /dev/null
+++ 
b/common/src/main/java/org/apache/drill/common/concurrent/AbstractCheckedFuture.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.concurrent;
+
+import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.ForwardingListenableFuture;
+import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture;
+
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * A delegating wrapper around a {@link ListenableFuture} that adds support 
for the {@link
+ * #checkedGet()} and {@link #checkedGet(long, TimeUnit)} methods.
+ *
+ * This class is moved from Guava, since there it was deleted.
+ */
+public abstract class AbstractCheckedFuture<T, E extends Exception>
+    extends ForwardingListenableFuture.SimpleForwardingListenableFuture<T> 
implements CheckedFuture<T, E> {
+
+  protected AbstractCheckedFuture(ListenableFuture<T> delegate) {
+    super(delegate);
+  }
+
+  /**
+   * Translates from an {@link InterruptedException},
+   * {@link CancellationException} or {@link ExecutionException} thrown by
+   * {@code get} to an exception of type {@code X} to be thrown by
+   * {@code checkedGet}. Subclasses must implement this method.
+   *
+   * <p>If {@code e} is an {@code InterruptedException}, the calling
+   * {@code checkedGet} method has already restored the interrupt after 
catching
+   * the exception. If an implementation of {@link #mapException(Exception)}
+   * wishes to swallow the interrupt, it can do so by calling
+   * {@link Thread#interrupted()}.
+   *
+   * <p>Subclasses may choose to throw, rather than return, a subclass of
+   * {@code RuntimeException} to allow creating a CheckedFuture that throws
+   * both checked and unchecked exceptions.
+   */
+  protected abstract E mapException(Exception e);
+
+  /**
+   * Exception checking version of {@link Future#get()} that will translate
+   * {@link InterruptedException}, {@link CancellationException} and
+   * {@link ExecutionException} into application-specific exceptions.
+   *
+   * @return the result of executing the future.
+   * @throws E on interruption, cancellation or execution exceptions.
+   */
+  public T checkedGet() throws E {
+    try {
+      return get();
+    } catch (InterruptedException e) {
+      Thread.currentThread().interrupt();
+      throw mapException(e);
+    } catch (CancellationException | ExecutionException e) {
+      throw mapException(e);
+    }
+  }
+
+  /**
+   * Exception checking version of {@link Future#get(long, TimeUnit)} that will
+   * translate {@link InterruptedException}, {@link CancellationException} and
+   * {@link ExecutionException} into application-specific exceptions.  On
+   * timeout this method throws a normal {@link TimeoutException}.
+   *
+   * @return the result of executing the future.
+   * @throws TimeoutException if retrieving the result timed out.
+   * @throws E on interruption, cancellation or execution exceptions.
+   */
+  public T checkedGet(long timeout, TimeUnit unit) throws TimeoutException, E {
+    try {
+      return get(timeout, unit);
+    } catch (InterruptedException e) {
+      Thread.currentThread().interrupt();
+      throw mapException(e);
+    } catch (CancellationException | ExecutionException e) {
+      throw mapException(e);
+    }
+  }
+}
diff --git 
a/common/src/main/java/org/apache/drill/common/concurrent/CheckedFuture.java 
b/common/src/main/java/org/apache/drill/common/concurrent/CheckedFuture.java
new file mode 100644
index 0000000..604b91a
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/concurrent/CheckedFuture.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.concurrent;
+
+import org.apache.drill.shaded.guava.com.google.common.util.concurrent.Futures;
+import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture;
+
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * A {@code CheckedFuture} is a {@link ListenableFuture} that includes 
versions of the {@code get}
+ * methods that can throw a checked exception. This makes it easier to create 
a future that executes
+ * logic which can throw an exception.
+ *
+ * <p>Implementations of this interface must adapt the exceptions thrown by 
{@code Future#get()}:
+ * {@link CancellationException}, {@link ExecutionException} and {@link 
InterruptedException} into
+ * the type specified by the {@code X} type parameter.
+ *
+ * <p>This interface also extends the ListenableFuture interface to allow 
listeners to be added.
+ * This allows the future to be used as a normal {@link Future} or as an 
asynchronous callback
+ * mechanism as needed. This allows multiple callbacks to be registered for a 
particular task, and
+ * the future will guarantee execution of all listeners when the task 
completes.
+ *
+ * <p>For a simpler alternative to CheckedFuture, consider accessing Future 
values with {@link
+ * Futures#getChecked(Future, Class) Futures.getChecked()}.
+ *
+ * This interface is moved from Guava, since there it was deleted.
+ *
+ */
+public interface CheckedFuture<V, X extends Exception> extends 
ListenableFuture<V> {
+
+  /**
+   * Exception checking version of {@link Future#get()} that will translate 
{@link
+   * InterruptedException}, {@link CancellationException} and {@link 
ExecutionException} into
+   * application-specific exceptions.
+   *
+   * @return the result of executing the future.
+   * @throws X on interruption, cancellation or execution exceptions.
+   */
+  V checkedGet() throws X;
+
+  /**
+   * Exception checking version of {@link Future#get(long, TimeUnit)} that 
will translate {@link
+   * InterruptedException}, {@link CancellationException} and {@link 
ExecutionException} into
+   * application-specific exceptions.  On timeout this method throws a normal 
{@link
+   * TimeoutException}.
+   *
+   * @return the result of executing the future.
+   * @throws TimeoutException if retrieving the result timed out.
+   * @throws X on interruption, cancellation or execution exceptions.
+   */
+  V checkedGet(long timeout, TimeUnit unit) throws TimeoutException, X;
+}
diff --git 
a/common/src/main/java/org/apache/drill/common/exceptions/DrillIOException.java 
b/common/src/main/java/org/apache/drill/common/exceptions/DrillIOException.java
index 7859d9a..5563402 100644
--- 
a/common/src/main/java/org/apache/drill/common/exceptions/DrillIOException.java
+++ 
b/common/src/main/java/org/apache/drill/common/exceptions/DrillIOException.java
@@ -20,7 +20,7 @@ package org.apache.drill.common.exceptions;
 import java.io.IOException;
 
 @SuppressWarnings("serial")
-public class DrillIOException extends IOException{
+public class DrillIOException extends IOException {
 
   public DrillIOException() { }
 
diff --git a/drill-shaded/drill-shaded-guava/pom.xml 
b/drill-shaded/drill-shaded-guava/pom.xml
index 83645d9..bd19430 100644
--- a/drill-shaded/drill-shaded-guava/pom.xml
+++ b/drill-shaded/drill-shaded-guava/pom.xml
@@ -28,11 +28,11 @@
   </parent>
 
   <artifactId>drill-shaded-guava</artifactId>
-  <version>23.0</version>
+  <version>28.2-jre</version>
   <name>drill-shaded/drill-shaded-guava</name>
 
   <properties>
-    <guava.version>23.0</guava.version>
+    <guava.version>${project.version}</guava.version>
   </properties>
 
   <dependencies>
@@ -52,6 +52,7 @@
           <artifactSet>
             <includes>
               <include>com.google.guava:guava</include>
+              <include>com.google.guava:failureaccess</include>
             </includes>
           </artifactSet>
           <relocations>
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java 
b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
index c215a93..48c61e1 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
@@ -17,12 +17,12 @@
  */
 package org.apache.drill.exec.rpc.user;
 
+import org.apache.drill.common.concurrent.AbstractCheckedFuture;
+import org.apache.drill.common.concurrent.CheckedFuture;
 import org.apache.drill.shaded.guava.com.google.common.base.Strings;
 import org.apache.drill.shaded.guava.com.google.common.base.Throwables;
 import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
 import org.apache.drill.shaded.guava.com.google.common.collect.Sets;
-import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.AbstractCheckedFuture;
-import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.CheckedFuture;
 import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.SettableFuture;
 import com.google.protobuf.MessageLite;
 import io.netty.buffer.ByteBuf;
diff --git a/exec/jdbc-all/pom.xml b/exec/jdbc-all/pom.xml
index 80a2d75..4504136 100644
--- a/exec/jdbc-all/pom.xml
+++ b/exec/jdbc-all/pom.xml
@@ -459,6 +459,7 @@
                
<exclude>org/apache/drill/shaded/guava/com/google/common/collect/Tree*</exclude>
                
<exclude>org/apache/drill/shaded/guava/com/google/common/collect/Standard*</exclude>
                
<exclude>org/apache/drill/shaded/guava/com/google/common/io/BaseEncoding*</exclude>
+               
<exclude>org/apache/drill/shaded/guava/com/google/common/graph/**</exclude>
                <exclude>com/google/common/math</exclude>
                <exclude>com/google/common/net</exclude>
                <exclude>com/google/common/primitives</exclude>
@@ -787,6 +788,7 @@
                       
<exclude>org/apache/drill/shaded/guava/com/google/common/graph/**</exclude>
                       
<exclude>org/apache/drill/shaded/guava/com/google/common/collect/Tree*</exclude>
                       
<exclude>org/apache/drill/shaded/guava/com/google/common/collect/Standard*</exclude>
+                      
<exclude>org/apache/drill/shaded/guava/com/google/common/graph/**</exclude>
                       <exclude>com/google/common/math</exclude>
                       <exclude>com/google/common/net</exclude>
                       <exclude>com/google/common/primitives</exclude>
diff --git 
a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFuture.java 
b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFuture.java
index 388bd43..2846a41 100644
--- a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFuture.java
+++ b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFuture.java
@@ -18,11 +18,12 @@
 package org.apache.drill.exec.rpc;
 
 import io.netty.buffer.ByteBuf;
+import org.apache.drill.common.concurrent.CheckedFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.CheckedFuture;
+public interface DrillRpcFuture<T> extends CheckedFuture<T, RpcException> {
+  Logger logger = LoggerFactory.getLogger(DrillRpcFuture.class);
 
-public interface DrillRpcFuture<T> extends CheckedFuture<T,RpcException> {
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(DrillRpcFuture.class);
-
-  public ByteBuf getBuffer();
+  ByteBuf getBuffer();
 }
diff --git 
a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFutureImpl.java 
b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFutureImpl.java
index 60511d1..c274cb1 100644
--- a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFutureImpl.java
+++ b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/DrillRpcFutureImpl.java
@@ -19,16 +19,15 @@ package org.apache.drill.exec.rpc;
 
 import io.netty.buffer.ByteBuf;
 
-import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.AbstractCheckedFuture;
+import org.apache.drill.common.concurrent.AbstractCheckedFuture;
 import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.AbstractFuture;
 
-class DrillRpcFutureImpl<V> extends AbstractCheckedFuture<V, RpcException> 
implements DrillRpcFuture<V>, RpcOutcomeListener<V>{
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(DrillRpcFutureImpl.class);
-
+class DrillRpcFutureImpl<V> extends AbstractCheckedFuture<V, RpcException>
+    implements DrillRpcFuture<V>, RpcOutcomeListener<V> {
   private volatile ByteBuf buffer;
 
   public DrillRpcFutureImpl() {
-    super(new InnerFuture<V>());
+    super(new InnerFuture<>());
   }
 
   @Override
@@ -51,19 +50,19 @@ class DrillRpcFutureImpl<V> extends 
AbstractCheckedFuture<V, RpcException> imple
 
   @Override
   public void failed(RpcException ex) {
-    ( (InnerFuture<V>)delegate()).setException(ex);
+    ((InnerFuture<V>) delegate()).setException(ex);
   }
 
   @Override
   public void success(V value, ByteBuf buffer) {
     this.buffer = buffer;
-    ( (InnerFuture<V>)delegate()).setValue(value);
+    ((InnerFuture<V>) delegate()).setValue(value);
   }
 
   @Override
   public void interrupted(final InterruptedException ex) {
     // Propagate the interrupt to inner future
-    ( (InnerFuture<V>)delegate()).cancel(true);
+    delegate().cancel(true);
   }
 
   @Override
diff --git 
a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCheckedFuture.java 
b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCheckedFuture.java
index cbebbb8..bb74c84 100644
--- a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCheckedFuture.java
+++ b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCheckedFuture.java
@@ -19,12 +19,12 @@ package org.apache.drill.exec.rpc;
 
 import io.netty.buffer.ByteBuf;
 
-import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.AbstractCheckedFuture;
+import org.apache.drill.common.concurrent.AbstractCheckedFuture;
 import 
org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture;
 
-public class RpcCheckedFuture<T> extends AbstractCheckedFuture<T, 
RpcException> implements DrillRpcFuture<T>{
+public class RpcCheckedFuture<T> extends AbstractCheckedFuture<T, 
RpcException> implements DrillRpcFuture<T> {
 
-  volatile ByteBuf buffer;
+  private volatile ByteBuf buffer;
 
   public RpcCheckedFuture(ListenableFuture<T> delegate) {
     super(delegate);
diff --git a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcException.java 
b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcException.java
index 4fe9457..50814ee 100644
--- a/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcException.java
+++ b/exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcException.java
@@ -26,9 +26,8 @@ import org.apache.drill.exec.proto.UserBitShared.DrillPBError;
 /**
  * Parent class for all rpc exceptions.
  */
-public class RpcException extends DrillIOException{
+public class RpcException extends DrillIOException {
   private static final long serialVersionUID = -5964230316010502319L;
-  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(RpcException.class);
 
   public RpcException() {
     super();
@@ -52,7 +51,7 @@ public class RpcException extends DrillIOException{
 
   public static RpcException mapException(Throwable t) {
     while (t instanceof ExecutionException) {
-      t = ((ExecutionException)t).getCause();
+      t = t.getCause();
     }
     if (t instanceof RpcException) {
       return ((RpcException) t);
@@ -62,16 +61,16 @@ public class RpcException extends DrillIOException{
 
   public static RpcException mapException(String message, Throwable t) {
     while (t instanceof ExecutionException) {
-      t = ((ExecutionException)t).getCause();
+      t = t.getCause();
     }
     return new RpcException(message, t);
   }
 
-  public boolean isRemote(){
+  public boolean isRemote() {
     return false;
   }
 
-  public DrillPBError getRemoteError(){
+  public DrillPBError getRemoteError() {
     throw new UnsupportedOperationException();
   }
 }
diff --git a/pom.xml b/pom.xml
index 0c8028c..6e4bdd1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
     <proto.cas.path>${project.basedir}/src/main/protobuf/</proto.cas.path>
     <junit.version>4.12</junit.version>
     <slf4j.version>1.7.26</slf4j.version>
-    <shaded.guava.version>23.0</shaded.guava.version>
+    <shaded.guava.version>28.2-jre</shaded.guava.version>
     <guava.version>19.0</guava.version>
     <forkCount>2</forkCount>
     <parquet.version>1.11.0</parquet.version>

Reply via email to