-
Notifications
You must be signed in to change notification settings - Fork 96
GH-863: [JDBC] Suppress benign exceptions from gRPC layer on ArrowFlightSqlClientHandler#close #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ennuite
wants to merge
5
commits into
apache:main
Choose a base branch
from
ennuite:pr-864-remove-jmeter-exceptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fff1e4b
ARROW-17785: [Flight SQL][JDBC] Suppress benign CloseSession errors w…
417947a
ARROW-17785: [Java][FlightSQL] Add comprehensive tests for CloseSessi…
39f86fa
ARROW-17785: [Java][FlightSQL] Fix null pointer bug and improve test …
dc63285
GH-863: Fix log level and formatting
ennuite b3b006b
GH-863: Simplify tests
ennuite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...re/src/test/java/org/apache/arrow/driver/jdbc/client/ArrowFlightSqlClientHandlerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * 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.arrow.driver.jdbc.client; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.doThrow; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| import java.sql.SQLException; | ||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.Optional; | ||
| import org.apache.arrow.flight.CallOption; | ||
| import org.apache.arrow.flight.CallStatus; | ||
| import org.apache.arrow.flight.CloseSessionRequest; | ||
| import org.apache.arrow.flight.FlightStatusCode; | ||
| import org.apache.arrow.flight.sql.FlightSqlClient; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| public class ArrowFlightSqlClientHandlerTest { | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource | ||
| public void testCloseHandlesFlightRuntimeException( | ||
| boolean throwFromCloseSession, CallStatus callStatus, boolean shouldSuppress) | ||
| throws Exception { | ||
| FlightSqlClient sqlClient = mock(FlightSqlClient.class); | ||
| String cacheKey = "cacheKey"; | ||
| Optional<String> catalog = | ||
| throwFromCloseSession ? Optional.of("test_catalog") : Optional.empty(); | ||
| final Collection<CallOption> credentialOptions = new ArrayList<>(); | ||
| ArrowFlightSqlClientHandler.Builder builder = new ArrowFlightSqlClientHandler.Builder(); | ||
|
|
||
| if (throwFromCloseSession) { | ||
| doThrow(callStatus.toRuntimeException()) | ||
| .when(sqlClient) | ||
| .closeSession(any(CloseSessionRequest.class), any(CallOption[].class)); | ||
| } else { | ||
| doThrow(callStatus.toRuntimeException()).when(sqlClient).close(); | ||
| } | ||
|
|
||
| ArrowFlightSqlClientHandler sqlClientHandler = | ||
| new ArrowFlightSqlClientHandler( | ||
| cacheKey, sqlClient, builder, credentialOptions, catalog, null); | ||
|
|
||
| if (shouldSuppress) { | ||
| assertDoesNotThrow(sqlClientHandler::close); | ||
| } else { | ||
| assertThrows(SQLException.class, sqlClientHandler::close); | ||
| } | ||
| } | ||
|
|
||
| private static Object[] testCloseHandlesFlightRuntimeException() { | ||
| CallStatus benignInternalError = | ||
| new CallStatus(FlightStatusCode.INTERNAL, null, "Connection closed after GOAWAY", null); | ||
| CallStatus notBenignInternalError = | ||
| new CallStatus(FlightStatusCode.INTERNAL, null, "Not a benign internal error", null); | ||
| CallStatus unavailableError = new CallStatus(FlightStatusCode.UNAVAILABLE, null, null, null); | ||
| CallStatus unknownError = new CallStatus(FlightStatusCode.UNKNOWN, null, null, null); | ||
| return new Object[] { | ||
| new Object[] {true, benignInternalError, true}, | ||
| new Object[] {false, benignInternalError, true}, | ||
| new Object[] {true, notBenignInternalError, false}, | ||
| new Object[] {false, notBenignInternalError, false}, | ||
| new Object[] {true, unavailableError, true}, | ||
| new Object[] {false, unavailableError, true}, | ||
| new Object[] {true, unknownError, false}, | ||
| new Object[] {false, unknownError, false}, | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still prefer debug level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Debug makes more sense to me here.