private void ensureValid(SharedClassObject obj) throws IllegalStateException { if (invalid != null) { String msg; if (obj != null) { msg = obj.toString(); } else { msg = "<unknown object>"; // NOI18N } throw (IllegalStateException) new IllegalStateException(msg).initCause(invalid); } // else fine }
@Override public synchronized Object setProperty(String key, String value) { if (propertReadAt.containsKey(key) && !value.equals(super.getProperty(key))) { IllegalStateException e = new IllegalStateException("Changing property '" + key + "' to '" + value + "' after it has already been read as '" + super.getProperty(key) + "'"); e.initCause(propertReadAt.get(key)); throw e; } return super.setProperty(key, value); }
public String getEncoding() { if (!isInited) { try { init(); } catch (IOException ex) { IllegalStateException ise = new IllegalStateException("Init method failed."); ise.initCause(ise); throw ise; } } return encoding; }
@Override public void release() { try { tx.rollback(); } catch (IOException unexpected) { IllegalStateException e = new IllegalStateException(unexpected); e.initCause(unexpected); throw e; } } }
private <Analysis> Analysis getMethodAnalysisNoException(Class<Analysis> analysisClass, Method method) { try { return getMethodAnalysis(analysisClass, method); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("should not happen"); ise.initCause(e); throw ise; } }
private <Analysis> Analysis getMethodAnalysisNoDataflowAnalysisException(Class<Analysis> analysisClass, Method method) throws CFGBuilderException { try { return getMethodAnalysis(analysisClass, method); } catch (CFGBuilderException e) { throw e; } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("should not happen"); ise.initCause(e); throw ise; } }
/** * Returns the {@linkplain InetAddress#getCanonicalHostName canonical name} of the local machine. */ protected static String getLocalHostName() { try { return SocketCreator.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException ex) { IllegalStateException ex2 = new IllegalStateException( "Could not determine localhost?!"); ex2.initCause(ex); throw ex2; } }
private <Analysis> Analysis getClassAnalysisNoException(Class<Analysis> analysisClass) { try { return getClassAnalysis(analysisClass); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("should not happen"); ise.initCause(e); throw ise; } }
@Override public void remove() { try { synchronized (indexLock) { tx.execute(new Transaction.Closure<IOException>() { @Override public void execute(Transaction tx) throws IOException { iterator.remove(); } }); } } catch (IOException unexpected) { IllegalStateException e = new IllegalStateException(unexpected); e.initCause(unexpected); throw e; } }
private void tryToInitialize(SharedClassObject obj) throws IllegalStateException { initializeInProgress = true; obj.initializeSuper = false; try { obj.initialize(); } catch (Exception e) { invalid = e; throw (IllegalStateException) new IllegalStateException(invalid.toString() + " from " + obj).initCause(invalid); // NOI18N } catch (LinkageError e) { invalid = e; throw (IllegalStateException) new IllegalStateException(invalid.toString() + " from " + obj).initCause(invalid); // NOI18N } finally { initializeInProgress = false; } if (!obj.initializeSuper) { String msg = "You must call super.initialize() from " + obj.getClass().getName() + ".initialize()"; // NOI18N err.warning(msg); } }
@Override public <E> void eagerlyPutMethodAnalysis(Class<E> analysisClass, @Nonnull MethodDescriptor methodDescriptor, E analysisObject) { try { ClassContext classContext = getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor()); assert analysisClass.isInstance(analysisObject); classContext.putMethodAnalysis(analysisClass, methodDescriptor, analysisObject); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("Unexpected exception adding method analysis to cache"); ise.initCause(e); throw ise; } }
@Override public void purgeMethodAnalyses(@Nonnull MethodDescriptor methodDescriptor) { try { ClassContext classContext = getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor()); classContext.purgeMethodAnalyses(methodDescriptor); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("Unexpected exception purging method analyses from cache"); ise.initCause(e); throw ise; } }
private <Analysis> Analysis getMethodAnalysis(Class<Analysis> analysisClass, Method method) throws DataflowAnalysisException, CFGBuilderException { try { MethodDescriptor methodDescriptor = BCELUtil.getMethodDescriptor(jclass, method); return Global.getAnalysisCache().getMethodAnalysis(analysisClass, methodDescriptor); } catch (DataflowAnalysisException e) { throw e; } catch (CFGBuilderException e) { throw e; } catch (CheckedAnalysisException e) { Throwable cause = e.getCause(); if (cause instanceof CFGBuilderException) { throw (CFGBuilderException) cause; } String message = "Should not happen: bad CAE: " + e.getClass().getName() + " for " + analysisClass.getName() + " of " + method; IllegalStateException ise = new IllegalStateException(message); ise.initCause(e); throw ise; } }
public void afterReceiveRequest(TransactionRequest request) throws IllegalStateException { TransactionContext srcTransactionContext = request.getTransactionContext(); if (srcTransactionContext == null) { return; } TransactionParticipant compensableCoordinator = this.beanFactory.getCompensableNativeParticipant(); TransactionContext transactionContext = srcTransactionContext.clone(); transactionContext.setPropagatedBy(srcTransactionContext.getPropagatedBy()); try { compensableCoordinator.start(transactionContext, XAResource.TMNOFLAGS); } catch (XAException ex) { logger.error("CompensableInterceptorImpl.afterReceiveRequest({})", request, ex); IllegalStateException exception = new IllegalStateException(); exception.initCause(ex); throw exception; } }
ex.initCause(anEx); Exceptions.attachLocalizedMessage(ex, "Cannot createClone for " + this); // NOI18N
@Override public void unaryCall(SimpleRequest request, StreamObserver<SimpleResponse> responseObserver) { IllegalStateException e1 = new IllegalStateException("Exception 1"); IllegalArgumentException e2 = new IllegalArgumentException(); AssertionError e3 = new AssertionError("Exception 3"); Exceptions.clearTrace(e3); RuntimeException e4 = new RuntimeException("Exception 4"); e1.initCause(e2); e2.initCause(e3); e3.initCause(e4); Status status = Status.ABORTED.withCause(e1); responseObserver.onError(status.asRuntimeException()); } }
/** * Get the ClassContext for a class. * * @param javaClass * the class * @return the ClassContext for that class */ public ClassContext getClassContext(JavaClass javaClass) { // This is a bit silly since we're doing an unnecessary // ClassDescriptor->JavaClass lookup. // However, we can be assured that it will succeed. ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor( ClassName.toSlashedClassName(javaClass.getClassName())); try { return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("Could not get ClassContext for JavaClass"); ise.initCause(e); throw ise; } }
public void beforeSendResponse(TransactionResponse response) throws IllegalStateException { CompensableManager compensableManager = this.beanFactory.getCompensableManager(); CompensableTransaction transaction = compensableManager.getCompensableTransactionQuietly(); if (transaction == null) { return; } TransactionParticipant compensableCoordinator = this.beanFactory.getCompensableNativeParticipant(); TransactionContext srcTransactionContext = transaction.getTransactionContext(); TransactionContext transactionContext = srcTransactionContext.clone(); transactionContext.setPropagatedBy(srcTransactionContext.getPropagatedBy()); response.setTransactionContext(transactionContext); try { compensableCoordinator.end(transactionContext, XAResource.TMSUCCESS); } catch (XAException ex) { logger.error("CompensableInterceptorImpl.beforeSendResponse({})", response, ex); IllegalStateException exception = new IllegalStateException(); exception.initCause(ex); throw exception; } }
} catch (Exception e) { IllegalStateException ise = new IllegalStateException("Could not configure WireFormatInfo"); ise.initCause(e); throw ise;