Skip to content

Commit 0989414

Browse files
committed
feedback
1 parent 98aa013 commit 0989414

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,13 +961,16 @@ void processQueryResponse(String query, TableResult results) throws SQLException
961961
}
962962

963963
private boolean isPermissionDeniedException(Throwable t) {
964-
if (t == null) {
965-
return false;
966-
}
967-
if (t instanceof StatusRuntimeException) {
968-
return ((StatusRuntimeException) t).getStatus().getCode() == Status.Code.PERMISSION_DENIED;
964+
while (t != null) {
965+
if (t instanceof StatusRuntimeException) {
966+
return ((StatusRuntimeException) t).getStatus().getCode() == Status.Code.PERMISSION_DENIED;
967+
}
968+
if (t instanceof ApiException) {
969+
return ((ApiException) t).getStatusCode().getCode() == StatusCode.Code.PERMISSION_DENIED;
970+
}
971+
t = t.getCause();
969972
}
970-
return isPermissionDeniedException(t.getCause());
973+
return false;
971974
}
972975

973976
// The read Ratio should be met

java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static com.google.common.truth.Truth.assertThat;
2121
import static org.junit.jupiter.api.Assertions.assertEquals;
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
23+
import static org.junit.jupiter.api.Assertions.fail;
2324
import static org.mockito.ArgumentMatchers.any;
2425
import static org.mockito.ArgumentMatchers.eq;
2526
import static org.mockito.Mockito.doReturn;
@@ -68,7 +69,6 @@
6869
import org.apache.arrow.vector.FieldVector;
6970
import org.apache.arrow.vector.IntVector;
7071
import org.apache.arrow.vector.VectorSchemaRoot;
71-
import org.junit.jupiter.api.Assertions;
7272
import org.junit.jupiter.api.BeforeEach;
7373
import org.junit.jupiter.api.Disabled;
7474
import org.junit.jupiter.api.Test;
@@ -551,7 +551,7 @@ public void testProcessQueryResponseNoFallbackOnNonPermissionFailure() throws SQ
551551
// Assert that the exception is propagated
552552
try {
553553
statementSpy.processQueryResponse("SELECT 1", tableResultMock);
554-
Assertions.fail("Expected SQLException to be thrown");
554+
fail("Expected SQLException to be thrown");
555555
} catch (SQLException e) {
556556
assertEquals(exceptionToThrow, e);
557557
}

0 commit comments

Comments
 (0)