/** * add admin users if they don't exist. * * This is a potential contention when HiveServer2 using embedded metastore and Metastore * Server try to concurrently invoke addAdminUsers. If one failed, JDOException was caught for * one more time try, if failed again, simply ignored by warning, which meant another succeeds. * * @throws MetaException */ private void addAdminUsers() throws MetaException { try { addAdminUsers_core(); } catch (JDOException e) { LOG.warn("Retrying adding admin users after error: " + e.getMessage(), e); addAdminUsers_core(); } }
@Override public void onEvent(PreEventContext context) throws MetaException, NoSuchObjectException, InvalidOperationException { callCount++; if (throwException) { throwException = false; throw new JDOException(); } throwException = true; }
if (jdoe.getNestedExceptions() != null) return new PersistenceException(jdoe.getMessage(), jdoe.getCause()); return new PersistenceException(jdoe.getMessage(), jdoe); return new EntityNotFoundException(jdoe.getMessage()); if (jdoe.getNestedExceptions() != null) return new PersistenceException(jdoe.getMessage(), jdoe.getCause()); return new PersistenceException(jdoe.getMessage(), jdoe); if (jdoe.getNestedExceptions() != null) return new OptimisticLockException(jdoe.getMessage(), jdoe.getCause()); return new OptimisticLockException(jdoe.getMessage(), jdoe); if (jdoe.getNestedExceptions() != null) return new PersistenceException(jdoe.getMessage(), jdoe.getCause()); return new PersistenceException(jdoe.getMessage(), jdoe);
/** * This implementation delegates to PersistenceManagerFactoryUtils. * @see PersistenceManagerFactoryUtils#convertJdoAccessException */ public DataAccessException translateException(JDOException ex) { if (ex.getCause() instanceof SQLException) { return getJdbcExceptionTranslator().translate("JDO operation: " + ex.getMessage(), extractSqlStringFromException(ex), (SQLException) ex.getCause()); } return PersistenceManagerFactoryUtils.convertJdoAccessException(ex); }
/** * Prints this <code>JDOException</code> and its backtrace to the * standard error output. * Print nested Throwables' stack trace as well. */ public void printStackTrace() { printStackTrace (System.err); }
/** * Method to do a refresh of objects that failed verification in the * exception. * @param exc The JDO exception containing the objects that failed */ public void refreshAll(JDOException exc) { Object obj = exc.getFailedObject(); if (obj != null) { refresh(obj); } Throwable[] nestedExceptions = exc.getNestedExceptions(); if (nestedExceptions != null) { for (Throwable nestedExc : nestedExceptions) { if (nestedExc instanceof JDOException) { refreshAll((JDOException) nestedExc); } } } }
private static Throwable causeOf(Throwable ex) { if (ex instanceof JDOException) { final JDOException jdoException = (JDOException) ex; final Throwable[] nestedExceptions = jdoException.getNestedExceptions(); return nestedExceptions != null && nestedExceptions.length > 0? nestedExceptions[0]: null; } else { return ex.getCause(); } }
if (objectId == null) { failedToString = msg.msg("MSG_ExceptionGettingFailedToString", //NOI18N exceptionToString(ex)); objectIdToString = exceptionToString(ex2); exceptionToString(ex), objectIdToString);
if (jdoe.getNestedExceptions() != null) return new PersistenceException(jdoe.getMessage(), jdoe.getCause()); return new PersistenceException(jdoe.getMessage(), jdoe); return new EntityNotFoundException(jdoe.getMessage()); if (jdoe.getNestedExceptions() != null) return new PersistenceException(jdoe.getMessage(), jdoe.getCause()); return new PersistenceException(jdoe.getMessage(), jdoe); if (jdoe.getNestedExceptions() != null) return new OptimisticLockException(jdoe.getMessage(), jdoe.getCause()); return new OptimisticLockException(jdoe.getMessage(), jdoe); if (jdoe.getNestedExceptions() != null) return new PersistenceException(jdoe.getMessage(), jdoe.getCause()); return new PersistenceException(jdoe.getMessage(), jdoe);
/** * This implementation delegates to PersistenceManagerFactoryUtils. * @see PersistenceManagerFactoryUtils#convertJdoAccessException */ @Override public DataAccessException translateException(JDOException ex) { if (getJdbcExceptionTranslator() != null && ex.getCause() instanceof SQLException) { return getJdbcExceptionTranslator().translate("JDO operation: " + ex.getMessage(), extractSqlStringFromException(ex), (SQLException) ex.getCause()); } return PersistenceManagerFactoryUtils.convertJdoAccessException(ex); }
/** * Prints this <code>JDOException</code> and its backtrace to the * standard error output. * Print nested Throwables' stack trace as well. */ public void printStackTrace() { printStackTrace (System.err); }
/** * Method to do a refresh of objects that failed verification in the * exception. * @param exc The JDO exception containing the objects that failed * @since 1.1 */ public synchronized void refreshAll(JDOException exc) { Object obj = exc.getFailedObject(); if (obj != null) { refresh(obj); } Throwable[] nested_excs = exc.getNestedExceptions(); if (nested_excs != null) { for (int i = 0; i < nested_excs.length; i++) { if (nested_excs[i] instanceof JDOException) { refreshAll((JDOException) nested_excs[i]); } } } }
@Override public void refreshAll(JDOException arg0) { DBTracer.logCall(this, arg0); checkOpen(); //We can't use HashSet because it may call an object's hashCode() and activateRead(). ObjectIdentitySet<Object> failed = new ObjectIdentitySet<>(); for (Throwable t: arg0.getNestedExceptions()) { Object f = ((JDOOptimisticVerificationException)t).getFailedObject(); failed.add(f); } nativeConnection.refreshAll(failed); }
if (objectId == null) { failedToString = msg.msg("MSG_ExceptionGettingFailedToString", //NOI18N exceptionToString(ex)); objectIdToString = exceptionToString(ex2); exceptionToString(ex), objectIdToString);
/** * create default roles if they don't exist. * * This is a potential contention when HiveServer2 using embedded metastore and Metastore * Server try to concurrently invoke createDefaultRoles. If one failed, JDOException was caught * for one more time try, if failed again, simply ignored by warning, which meant another * succeeds. * * @throws MetaException */ private void createDefaultRoles() throws MetaException { try { createDefaultRoles_core(); } catch (JDOException e) { LOG.warn("Retrying creating default roles after error: " + e.getMessage(), e); createDefaultRoles_core(); } }
@Test public void testWrappedMetaExceptionRetry() throws MetaException { IHMSHandler mockBaseHandler = Mockito.mock(IHMSHandler.class); Mockito.when(mockBaseHandler.getConf()).thenReturn(conf); //JDOException wrapped in MetaException wrapped in InvocationException MetaException me = new MetaException("Dummy exception"); me.initCause(new JDOException()); InvocationTargetException ex = new InvocationTargetException(me); Mockito .doThrow(me) .doNothing() .when(mockBaseHandler).init(); RetryingHMSHandler.getProxy(conf, mockBaseHandler, false); Mockito.verify(mockBaseHandler, Mockito.times(2)).init(); } }
throw rollbackEx; // Throw if the tx wasn't rolled back. LOG.info("Ignoring exception, rollback succeeded: " + rollbackEx.getMessage());
/** * * @param conn_factory Connection factory */ public void setConnectionFactory(Object conn_factory) { throw new JDOException("Not available in managed environment"); }
enhancer = JDOHelper.getEnhancer(); } catch (JDOException jdoex) { jdoex.printStackTrace(); // outputs to stderr exit(ENHANCER_NO_JDO_ENHANCER_FOUND);