Fix error categorization in local file connector
Exceptions are wrapped by LoadingCache and must be unwrapped.
package com.facebook.presto.localfile;
import com.facebook.presto.spi.ColumnMetadata;
+import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.SchemaTableName;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import javax.annotation.Nonnull;
import javax.inject.Inject;
@@ -39,6 +41,7 @@ import static com.facebook.presto.spi.type.BigintType.BIGINT;
import static com.facebook.presto.spi.type.TimestampType.TIMESTAMP;
import static com.facebook.presto.spi.type.VarcharType.createUnboundedVarcharType;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Throwables.throwIfInstanceOf;
import static java.util.concurrent.TimeUnit.SECONDS;
public class LocalFileTables
@@ -108,8 +111,14 @@ public class LocalFileTables
public List<File> getFiles(SchemaTableName table)
{
+ try {
return cachedFiles.getUnchecked(table);
}
+ catch (UncheckedExecutionException e) {
+ throwIfInstanceOf(e.getCause(), PrestoException.class);
+ throw e;
+ }
+ }
public static class HttpRequestLogTable
{
