Skip to content

Commit

Permalink
Enable Error Prone check: CheckedExceptionNotThrown
Browse files Browse the repository at this point in the history
The issue with this is that:

* This is an experimental checker
* It has a huge number of false negatives

Regarding the second point, it may be that making it more accurate would
make it unviably slow (the equivalent inspection in IntelliJ IDEA takes
a lot of time, has to look at the whole code base - it's definitely not
local - and has to be done repeatedly until nothing more is found). But
perhaps it's still useful.
  • Loading branch information
ksobolew committed Aug 30, 2022
1 parent 5120f3f commit 9d1c7a6
Show file tree
Hide file tree
Showing 16 changed files with 9 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class InputReader
private final LineReader reader;

public InputReader(ClientOptions.EditingMode editingMode, Path historyFile, boolean disableAutoSuggestion, Completer... completers)
throws IOException
{
reader = LineReaderBuilder.builder()
.terminal(TerminalUtils.getTerminal())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,6 @@ private static void optionalStringInFilter(List<String> filters, String columnNa

@Nullable
private String escapeIfNecessary(@Nullable String namePattern)
throws SQLException
{
return escapeIfNecessary(assumeLiteralNamesInMetadataCallsForNonConformingClients, assumeLiteralUnderscoreInMetadataCallsForNonConformingClients, namePattern);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static TrinoResultSet create(Statement statement, StatementClient client, long m
}

private TrinoResultSet(Statement statement, StatementClient client, List<Column> columns, long maxRows, Consumer<QueryStats> progressCallback, WarningsManager warningsManager)
throws SQLException
{
super(
Optional.of(requireNonNull(statement, "statement is null")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public static void input(
@AggregationState("T") InOut state,
@BlockPosition @SqlType("T") Block block,
@BlockIndex int position)
throws Throwable
{
if (state.isNull()) {
state.set(block, position);
Expand All @@ -50,7 +49,6 @@ public static void input(
public static void combine(
@AggregationState("T") InOut state,
@AggregationState("T") InOut otherState)
throws Throwable
{
if (state.isNull()) {
state.set(otherState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import io.trino.server.HttpRequestSessionContextFactory;
import io.trino.server.ProtocolConfig;
import io.trino.server.protocol.PreparedStatementEncoder;
import io.trino.server.security.oauth2.ChallengeFailedException;
import io.trino.server.security.oauth2.OAuth2Client;
import io.trino.server.security.oauth2.TokenPairSerializer;
import io.trino.server.security.oauth2.TokenPairSerializer.TokenPair;
Expand Down Expand Up @@ -912,7 +911,6 @@ public Optional<Map<String, Object>> getClaims(String accessToken)

@Override
public Response refreshTokens(String refreshToken)
throws ChallengeFailedException
{
throw new UnsupportedOperationException("refresh tokens not supported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ private AccumuloTable toAccumuloTable(byte[] data)
}

private AccumuloView toAccumuloView(byte[] data)
throws IOException
{
return parseJson(mapper, data, AccumuloView.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public LazyConnectionFactory(@ForLazyConnectionFactory ConnectionFactory delegat
}

@Override
@SuppressWarnings("CheckedExceptionNotThrown") // preserve the "throws" contract of the interface declaration
public Connection openConnection(ConnectorSession session)
throws SQLException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ public class TestingScyllaServer
private final CassandraSession session;

public TestingScyllaServer()
throws Exception
{
this("2.2.0");
}

public TestingScyllaServer(String version)
throws Exception
{
container = new GenericContainer<>("scylladb/scylla:" + version)
.withCommand("--smp", "1") // Limit SMP to run in a machine having many cores https://github.com/scylladb/scylla/issues/5638
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ else if (stats.isPresent()) {
try {
resultParsedStats = Optional.ofNullable(DeltaLakeJsonFileStatistics.create(stats.get()));
}
catch (JsonProcessingException e) {
catch (RuntimeException e) {
LOG.debug(
e,
"File level stats could not be parsed and will be ignored. The JSON string was: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.trino.plugin.deltalake.transactionlog;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.airlift.json.ObjectMapperProvider;
Expand Down Expand Up @@ -131,7 +130,6 @@ private TransactionLogParser() {}
.withResolverStyle(ResolverStyle.STRICT);

public static DeltaLakeTransactionLogEntry parseJson(String json)
throws JsonProcessingException
{
// lines are json strings followed by 'x' in some Databricks versions of Delta
if (json.endsWith("x")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.airlift.json.ObjectMapperProvider;
import io.airlift.log.Logger;
Expand Down Expand Up @@ -61,7 +60,6 @@ public class DeltaLakeJsonFileStatistics
private final Optional<Map<CanonicalColumnName, Object>> nullCount;

public static DeltaLakeJsonFileStatistics create(String jsonStatistics)
throws JsonProcessingException
{
return parseJson(OBJECT_MAPPER, jsonStatistics, DeltaLakeJsonFileStatistics.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ protected boolean isSplitable(FileSystem fs, Path filename)

@Override
public RecordReader<Void, Void> getRecordReader(InputSplit inputSplit, JobConf jobConf, Reporter reporter)
throws IOException
{
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.common.collect.Lists;
import io.airlift.http.client.HttpUriBuilder;
import io.airlift.units.Duration;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorSplit;
Expand All @@ -38,7 +37,6 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Instant;
import java.util.List;
import java.util.Map;
Expand All @@ -48,7 +46,6 @@
import java.util.stream.IntStream;

import static io.trino.plugin.prometheus.PrometheusClient.TIMESTAMP_COLUMN_TYPE;
import static io.trino.plugin.prometheus.PrometheusErrorCode.PROMETHEUS_UNKNOWN_ERROR;
import static io.trino.spi.type.DateTimeEncoding.unpackMillisUtc;
import static java.time.Instant.ofEpochMilli;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -93,24 +90,17 @@ public ConnectorSplitSource getSplits(
}
List<ConnectorSplit> splits = generateTimesForSplits(prometheusClock.now(), maxQueryRangeDuration, queryChunkSizeDuration, tableHandle)
.stream()
.map(time -> {
try {
return new PrometheusSplit(buildQuery(
prometheusURI,
time,
table.getName(),
queryChunkSizeDuration).toString());
}
catch (URISyntaxException e) {
throw new TrinoException(PROMETHEUS_UNKNOWN_ERROR, "split URI invalid: " + e.getMessage());
}
}).collect(Collectors.toList());
.map(time -> new PrometheusSplit(buildQuery(
prometheusURI,
time,
table.getName(),
queryChunkSizeDuration).toString()))
.collect(Collectors.toList());
return new FixedSplitSource(splits);
}

// HttpUriBuilder handles URI encode
private static URI buildQuery(URI baseURI, String time, String metricName, Duration queryChunkSizeDuration)
throws URISyntaxException
{
return HttpUriBuilder.uriBuilderFrom(baseURI)
.appendPath("api/v1/query")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ private void prepare(Connection connection)
}

private boolean hasSnapshotIsolationEnabled(Connection connection)
throws SQLException
{
try {
return snapshotIsolationEnabled.get(SnapshotIsolationEnabledCacheKey.INSTANCE, () -> {
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,7 @@
-Xplugin:ErrorProne \
-Xep:BadInstanceof:ERROR \
-Xep:BoxedPrimitiveConstructor:ERROR \
-Xep:CheckedExceptionNotThrown:ERROR \
-Xep:ClassCanBeStatic:ERROR \
-Xep:CompareToZero:ERROR \
-Xep:DefaultCharset:ERROR \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.trino.tempto.assertions.QueryAssert.Row;
import org.testng.annotations.Test;

import java.sql.SQLException;
import java.util.List;

import static com.google.common.collect.ImmutableList.toImmutableList;
Expand Down Expand Up @@ -77,7 +76,6 @@ public void testHiveViewPropertiesTable()
}

private static List<String> getTablePropertiesOnHive(String tableName)
throws SQLException
{
return onHive().executeQuery("SHOW TBLPROPERTIES " + tableName).rows().stream()
.map(row -> (String) row.get(1))
Expand Down

0 comments on commit 9d1c7a6

Please sign in to comment.