Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.3 27905e36e -> 4d5d68fea
PHOENIX-4941 Handle TableExistsException when wrapped under RemoteException for SYSTEM.MUTEX table(addendum) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/4d5d68fe Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4d5d68fe Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4d5d68fe Branch: refs/heads/4.x-HBase-1.3 Commit: 4d5d68fea87bd00ebd6cfb76e1e6b71e257aba0a Parents: 27905e3 Author: Ankit Singhal <[email protected]> Authored: Tue Oct 2 12:28:00 2018 -0700 Committer: Ankit Singhal <[email protected]> Committed: Tue Oct 2 12:28:00 2018 -0700 ---------------------------------------------------------------------- .../phoenix/query/ConnectionQueryServicesImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/4d5d68fe/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index d2ece24..dbfd461 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -2568,12 +2568,15 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement boolean foundAccessDeniedException = false; // when running spark/map reduce jobs the ADE might be wrapped // in a RemoteException - if (inspectIfAnyExceptionInChain(e, Collections.singletonList(AccessDeniedException.class))) { + if (inspectIfAnyExceptionInChain(e, Collections + .<Class<? extends Exception>> singletonList(AccessDeniedException.class))) { // Pass logger.warn("Could not check for Phoenix SYSTEM tables, assuming they exist and are properly configured"); checkClientServerCompatibility(SchemaUtil.getPhysicalName(SYSTEM_CATALOG_NAME_BYTES, getProps()).getName()); success = true; - } else if (inspectIfAnyExceptionInChain(e, Collections.singletonList(NamespaceNotFoundException.class))) { + } else if (inspectIfAnyExceptionInChain(e, + Collections.<Class<? extends Exception>> singletonList( + NamespaceNotFoundException.class))) { // This exception is only possible if SYSTEM namespace mapping is enabled and SYSTEM namespace is missing // It implies that SYSTEM tables are not created and hence we shouldn't provide a connection AccessDeniedException ade = new AccessDeniedException("Insufficient permissions to create SYSTEM namespace and SYSTEM Tables"); @@ -2670,7 +2673,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement admin.createTable(tableDesc); } catch (IOException e) { - if (inspectIfAnyExceptionInChain(e, Arrays.<Class<? extends IOException>> asList( + if (inspectIfAnyExceptionInChain(e, Arrays.<Class<? extends Exception>> asList( AccessDeniedException.class, org.apache.hadoop.hbase.TableExistsException.class))) { // Ignore TableExistsException as another client might beat us during upgrade. // Ignore AccessDeniedException, as it may be possible underpriviliged user trying to use the connection @@ -2683,10 +2686,10 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement } } - private boolean inspectIfAnyExceptionInChain(Throwable io, List<Class<? extends IOException>> ioList) { + private boolean inspectIfAnyExceptionInChain(Throwable io, List<Class<? extends Exception>> ioList) { boolean exceptionToIgnore = false; for (Throwable t : Throwables.getCausalChain(io)) { - for (Class<? extends IOException> exception : ioList) { + for (Class<? extends Exception> exception : ioList) { exceptionToIgnore |= isExceptionInstanceOf(t, exception); } if (exceptionToIgnore) { @@ -2697,7 +2700,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement return exceptionToIgnore; } - private boolean isExceptionInstanceOf(Throwable io, Class<? extends IOException> exception) { + private boolean isExceptionInstanceOf(Throwable io, Class<? extends Exception> exception) { return exception.isInstance(io) || (io instanceof RemoteException && (((RemoteException)io).getClassName().equals(exception.getName()))); }
