@Override public void onError(Throwable t) { if (done) { Operators.onErrorDropped(t, cachedContext); return; } done = true; try { //noinspection ConstantConditions onSignal.accept(Signal.error(t, cachedContext)); } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e t = Operators.onOperatorError(null, e, t, cachedContext); } try { actual.onError(t); } catch (UnsupportedOperationException use) { if (!Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use; } //ignore if missing callback } }
@Test public void onErrorCallbackNotImplemented() { Flux<String> flux = Flux.error(new IllegalStateException()); try { flux.subscribe(new BaseSubscriber<String>() { @Override protected void hookOnSubscribe(Subscription subscription) { request(1); } @Override protected void hookOnNext(String value) { //NO-OP } }); fail("expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { assertThat(e.getClass() .getSimpleName(), is("ErrorCallbackNotImplemented")); assertThat(e.getCause(), is(instanceOf(IllegalStateException.class))); } }
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Test public void cacheExceptionRewriteCallStack() { final String keyItem = name.getMethodName(); UnsupportedOperationException first = null; long ref = service.exceptionInvocations(); try { service.cacheWithException(keyItem, true); fail("Should have thrown an exception"); } catch (UnsupportedOperationException e) { first = e; } // Sanity check, this particular call has called the service assertEquals("First call should not have been cached", ref + 1, service.exceptionInvocations()); UnsupportedOperationException second = methodInCallStack(keyItem); // Sanity check, this particular call has *not* called the service assertEquals("Second call should have been cached", ref + 1, service.exceptionInvocations()); assertEquals(first.getCause(), second.getCause()); assertEquals(first.getMessage(), second.getMessage()); assertFalse("Original stack must not contain any reference to methodInCallStack", contain(first, AbstractJCacheAnnotationTests.class.getName(), "methodInCallStack")); assertTrue("Cached stack should have been rewritten with a reference to methodInCallStack", contain(second, AbstractJCacheAnnotationTests.class.getName(), "methodInCallStack")); }
!Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t){ throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
} catch (UnsupportedOperationException x) { if (!(x.getCause() instanceof NoStaplerConstructorException)) { LOG.log(Level.WARNING, "failed to uncoerce " + o, x);
} catch (UnsupportedOperationException x) { if (!(x.getCause() instanceof NoStaplerConstructorException)) { LOG.log(Level.WARNING, "failed to uncoerce " + o, x);
public synchronized Object eval(Event event) throws ProcessorException { logger.trace("Evaluating script {} with formatters {}", expression, formatters); Binding groovyBinding = new Binding(); groovyBinding.setVariable("event", event); groovyBinding.setVariable("formatters", formatters); Script localscript; try { localscript = groovyScript.get(); } catch (UnsupportedOperationException e) { throw event.buildException(String.format("script compilation failed '%s': %s", expression, e.getCause().getMessage())); } localscript.setBinding(groovyBinding); try { return localscript.run(); } catch (Exception e) { throw event.buildException(String.format("failed expression '%s': %s", expression, Helpers.resolveThrowableException(e))); } finally { localscript.setBinding(EMPTYBIDDING); } }
@Override public void onError(Throwable t) { if (done) { Operators.onErrorDropped(t, cachedContext); return; } done = true; try { //noinspection ConstantConditions onSignal.accept(Signal.error(t, cachedContext)); } catch (Throwable e) { //this performs a throwIfFatal or suppresses t in e t = Operators.onOperatorError(null, e, t, cachedContext); } try { actual.onError(t); } catch (UnsupportedOperationException use) { if (!Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use; } //ignore if missing callback } }
@Test public void testAs$notSupported() throws Exception { try { term().as(Double.class); fail("Should not cast to Double"); } catch (UnsupportedOperationException e) { assertThat(e.getCause(),instanceOf(CannotAdaptClassesException.class)); } }
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t){ throw use;
!Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
|| !Exceptions.isErrorCallbackNotImplemented(use) && use.getCause() != t) { throw use;
/** * Pre-evaluate a function at compile time. Functions that do not allow * pre-evaluation, or that need access to context information, can override this method. * * @param visitor an expression visitor * @return the result of the early evaluation, or the original expression, or potentially * a simplified expression * @throws net.sf.saxon.trans.XPathException if evaluation fails */ public Expression preEvaluate(ExpressionVisitor visitor) throws XPathException { if ((getIntrinsicDependencies() & ~StaticProperty.DEPENDS_ON_STATIC_CONTEXT) != 0) { return this; } try { Literal lit = Literal.makeLiteral(iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(), this); Optimizer.trace(visitor.getConfiguration(), "Pre-evaluated function call " + toShortString(), lit); return lit; } catch (NoDynamicContextException e) { // early evaluation failed, usually because implicit timezone required return this; } catch (UnsupportedOperationException e) { //e.printStackTrace(); if (e.getCause() instanceof NoDynamicContextException) { return this; } else { throw e; } } }
/** * Pre-evaluate a function at compile time. Functions that do not allow * pre-evaluation, or that need access to context information, can override this method. * * @param visitor an expression visitor * @return the result of the early evaluation, or the original expression, or potentially * a simplified expression * @throws net.sf.saxon.trans.XPathException if evaluation fails */ public Expression preEvaluate(ExpressionVisitor visitor) throws XPathException { if ((getIntrinsicDependencies() & ~StaticProperty.DEPENDS_ON_STATIC_CONTEXT) != 0) { return this; } try { Literal lit = Literal.makeLiteral(iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(), this); Optimizer.trace(visitor.getConfiguration(), "Pre-evaluated function call " + toShortString(), lit); return lit; } catch (NoDynamicContextException e) { // early evaluation failed, usually because implicit timezone required return this; } catch (UnsupportedOperationException e) { //e.printStackTrace(); if (e.getCause() instanceof NoDynamicContextException) { return this; } else { throw e; } } }