This is an automated email from the ASF dual-hosted git repository.
jhyde pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new a8e71f9 Remove calls to deprecated Guava API
a8e71f9 is described below
commit a8e71f9f295e36e472d9f650d1c76d2501e1fdbf
Author: Julian Hyde <[email protected]>
AuthorDate: Sun Apr 7 12:39:41 2019 -0700
Remove calls to deprecated Guava API
Throwables.propagate was deprecated in Guava 21.
Add '<p>' to a multi-paragraph javadoc comment, and edit for clarity.
---
.../java/org/apache/calcite/test/BabelParserTest.java | 11 ++++++-----
.../calcite/sql/type/SqlTypeAssignmentRules.java | 6 +++++-
.../calcite/statistic/CachingSqlStatisticProvider.java | 18 +++++++++++-------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/babel/src/test/java/org/apache/calcite/test/BabelParserTest.java
b/babel/src/test/java/org/apache/calcite/test/BabelParserTest.java
index 8e3d312..9f014af 100644
--- a/babel/src/test/java/org/apache/calcite/test/BabelParserTest.java
+++ b/babel/src/test/java/org/apache/calcite/test/BabelParserTest.java
@@ -160,15 +160,16 @@ public class BabelParserTest extends SqlParserTest {
}
/**
- * Babel parser's global LOOKAHEAD is larger than the core parser's, this
causes different
- * parse error message between these two parser types. Here we define a
looser error checker
- * for Babel to reuse failure testing codes from {@link SqlParserTest}.
+ * Babel parser's global {@code OOKAHEAD} is larger than the core
+ * parser's. This causes different parse error message between these two
+ * parsers. Here we define a looser error checker for Babel, so that we can
+ * reuse failure testing codes from {@link SqlParserTest}.
*
- * Test cases just written in this file is still checked by {@link
SqlParserTest}'s checker.
+ * <p>If a test case is written in this file -- that is, not inherited -- it
+ * is still checked by {@link SqlParserTest}'s checker.
*/
@Override protected Tester getTester() {
return new TesterImpl() {
-
@Override protected void checkEx(String expectedMsgPattern,
SqlParserUtil.StringAndPos sap, Throwable thrown) {
if (thrownByBabelTest(thrown)) {
diff --git
a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRules.java
b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRules.java
index 77f11fa..e6385eb 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRules.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRules.java
@@ -16,12 +16,15 @@
*/
package org.apache.calcite.sql.type;
+import org.apache.calcite.util.Util;
+
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import java.util.EnumSet;
import java.util.HashMap;
@@ -412,7 +415,8 @@ public class SqlTypeAssignmentRules {
void add(SqlTypeName fromType, Set<SqlTypeName> toTypes) {
try {
map.put(fromType, sets.get(toTypes));
- } catch (ExecutionException e) {
+ } catch (UncheckedExecutionException | ExecutionException e) {
+ Util.throwIfUnchecked(e.getCause());
throw new RuntimeException("populating SqlTypeAssignmentRules", e);
}
}
diff --git
a/core/src/main/java/org/apache/calcite/statistic/CachingSqlStatisticProvider.java
b/core/src/main/java/org/apache/calcite/statistic/CachingSqlStatisticProvider.java
index 6d6b6e9..abb3214 100644
---
a/core/src/main/java/org/apache/calcite/statistic/CachingSqlStatisticProvider.java
+++
b/core/src/main/java/org/apache/calcite/statistic/CachingSqlStatisticProvider.java
@@ -19,10 +19,11 @@ package org.apache.calcite.statistic;
import org.apache.calcite.materialize.SqlStatisticProvider;
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.util.ImmutableIntList;
+import org.apache.calcite.util.Util;
-import com.google.common.base.Throwables;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import java.util.List;
import java.util.concurrent.ExecutionException;
@@ -49,8 +50,9 @@ public class CachingSqlStatisticProvider implements
SqlStatisticProvider {
table.getQualifiedName());
return (Double) cache.get(key,
() -> provider.tableCardinality(table));
- } catch (ExecutionException e) {
- throw Throwables.propagate(e.getCause());
+ } catch (UncheckedExecutionException | ExecutionException e) {
+ Util.throwIfUnchecked(e.getCause());
+ throw new RuntimeException(e.getCause());
}
}
@@ -66,8 +68,9 @@ public class CachingSqlStatisticProvider implements
SqlStatisticProvider {
return (Boolean) cache.get(key,
() -> provider.isForeignKey(fromTable, fromColumns, toTable,
toColumns));
- } catch (ExecutionException e) {
- throw Throwables.propagate(e.getCause());
+ } catch (UncheckedExecutionException | ExecutionException e) {
+ Util.throwIfUnchecked(e.getCause());
+ throw new RuntimeException(e.getCause());
}
}
@@ -77,8 +80,9 @@ public class CachingSqlStatisticProvider implements
SqlStatisticProvider {
ImmutableList.of("isKey", table.getQualifiedName(),
ImmutableIntList.copyOf(columns));
return (Boolean) cache.get(key, () -> provider.isKey(table, columns));
- } catch (ExecutionException e) {
- throw Throwables.propagate(e.getCause());
+ } catch (UncheckedExecutionException | ExecutionException e) {
+ Util.throwIfUnchecked(e.getCause());
+ throw new RuntimeException(e.getCause());
}
}
}