* Fixes #2663 - Guard Throwable.addSuppressed() calls. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
f9b5949541
commit
253c637742
|
@ -63,7 +63,8 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
|
|||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(x);
|
||||
failure.addSuppressed(x);
|
||||
if (x != failure)
|
||||
failure.addSuppressed(x);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,8 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
|
|||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Could not initialize " + processor, x);
|
||||
failure.addSuppressed(x);
|
||||
if (x != failure)
|
||||
failure.addSuppressed(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1550,7 +1550,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
|||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
failure.addSuppressed(x);
|
||||
if (x != failure)
|
||||
failure.addSuppressed(x);
|
||||
complete();
|
||||
}
|
||||
|
||||
|
|
|
@ -310,8 +310,11 @@ abstract public class WriteFlusher
|
|||
FailedState failed = (FailedState)_state.get();
|
||||
|
||||
Throwable cause = failed.getCause();
|
||||
for(Throwable t : suppressed)
|
||||
cause.addSuppressed(t);
|
||||
for (Throwable t : suppressed)
|
||||
{
|
||||
if (t != cause)
|
||||
cause.addSuppressed(t);
|
||||
}
|
||||
|
||||
callback.failed(cause);
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public class AsyncContextEvent extends AsyncEvent implements Runnable
|
|||
{
|
||||
if (_throwable==null)
|
||||
_throwable=e;
|
||||
else if (_throwable != e)
|
||||
else if (e != _throwable)
|
||||
_throwable.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -428,7 +428,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
|||
}
|
||||
else
|
||||
{
|
||||
if (failure != x)
|
||||
if (x != failure)
|
||||
failure.addSuppressed(x);
|
||||
minimalErrorResponse(failure);
|
||||
}
|
||||
|
@ -579,7 +579,8 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
|||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
failure.addSuppressed(e);
|
||||
if (e != failure)
|
||||
failure.addSuppressed(e);
|
||||
LOG.warn("ERROR dispatch failed", failure);
|
||||
// Try to send a minimal response.
|
||||
minimalErrorResponse(failure);
|
||||
|
@ -597,7 +598,8 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
failure.addSuppressed(x);
|
||||
if (x != failure)
|
||||
failure.addSuppressed(x);
|
||||
abort(failure);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -593,10 +593,11 @@ public class HttpChannelState
|
|||
{
|
||||
LOG.warn(x+" while invoking onTimeout listener " + listener);
|
||||
LOG.debug(x);
|
||||
if (error.get()==null)
|
||||
Throwable failure = error.get();
|
||||
if (failure == null)
|
||||
error.set(x);
|
||||
else
|
||||
error.get().addSuppressed(x);
|
||||
else if (x != failure)
|
||||
failure.addSuppressed(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,15 +55,15 @@ public class MultiException extends Exception
|
|||
super(DEFAULT_MESSAGE);
|
||||
this.nested = new ArrayList<>(nested);
|
||||
|
||||
if(nested.size() > 0) {
|
||||
if (nested.size() > 0)
|
||||
initCause(nested.get(0));
|
||||
}
|
||||
|
||||
for(Throwable t : nested) {
|
||||
this.addSuppressed(t);
|
||||
|
||||
for (Throwable t : nested)
|
||||
{
|
||||
if (t != this)
|
||||
addSuppressed(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void add(Throwable e)
|
||||
|
@ -196,8 +196,10 @@ public class MultiException extends Exception
|
|||
th = new MultiException(Collections.emptyList());
|
||||
|
||||
for (Throwable s : nested)
|
||||
{
|
||||
if (s!=th)
|
||||
th.addSuppressed(s);
|
||||
}
|
||||
if (Error.class.isInstance(th))
|
||||
throw (Error)th;
|
||||
throw (Exception)th;
|
||||
|
|
|
@ -234,23 +234,4 @@ public abstract class AbstractLifeCycle implements LifeCycle
|
|||
@Override public void lifeCycleStopped(LifeCycle event) {}
|
||||
@Override public void lifeCycleStopping(LifeCycle event) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* A LifeCycle Listener that will call stop if any failures are notified.
|
||||
*/
|
||||
public static final LifeCycle.Listener STOP_ON_FAILURE = new AbstractLifeCycleListener()
|
||||
{
|
||||
@Override
|
||||
public void lifeCycleFailure(LifeCycle lifecycle, Throwable cause)
|
||||
{
|
||||
try
|
||||
{
|
||||
lifecycle.stop();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
cause.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -534,7 +534,7 @@ public class WebAppClassLoader extends URLClassLoader
|
|||
{
|
||||
if (ex==null)
|
||||
ex = e;
|
||||
else
|
||||
else if (e != ex)
|
||||
ex.addSuppressed(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue