Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3949 #3978

Merged
merged 1 commit into from
Sep 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixes #3949
If a checked exception is thrown from an interceptor allow RESTeasy
exception mappers to unwrap it.
  • Loading branch information
stuartwdouglas committed Sep 12, 2019
commit bdfafda7ff811a62ff78e9c50f18e99e4141424c
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

import io.quarkus.arc.ArcUndeclaredThrowableException;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem;
@@ -260,6 +261,8 @@ public void build(
resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_GZIP_MAX_INPUT,
Long.toString(commonConfig.gzip.maxInput.asLongValue()));
}
resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_UNWRAPPED_EXCEPTIONS,
ArcUndeclaredThrowableException.class.getName());

resteasyServerConfig.produce(new ResteasyServerConfigBuildItem(path, resteasyInitParameters));
}
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import static org.objectweb.asm.Opcodes.ACC_FINAL;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;

import io.quarkus.arc.ArcUndeclaredThrowableException;
import io.quarkus.arc.InjectableInterceptor;
import io.quarkus.arc.InvocationContextImpl.InterceptorInvocation;
import io.quarkus.arc.Subclass;
@@ -341,7 +342,7 @@ private void createForwardingMethod(ClassOutput classOutput, BeanInfo bean, Meth
if (addCatchException) {
CatchBlockCreator catchOtherExceptions = tryCatch.addCatch(Exception.class);
// and wrap them in a new RuntimeException(e)
catchOtherExceptions.throwException(RuntimeException.class, "Error invoking subclass method",
catchOtherExceptions.throwException(ArcUndeclaredThrowableException.class, "Error invoking subclass method",
catchOtherExceptions.getCaughtException());
}
// InvocationContextImpl.aroundInvoke(this, methods.get("m1"), params, interceptorChains.get("m1"), forward)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.arc;

/**
* Exception that is thrown from generated arc classes if a checked exception cannot be propagated
*/
public class ArcUndeclaredThrowableException extends RuntimeException {

public ArcUndeclaredThrowableException(Throwable cause) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if the name shouldn't be more general, something like ArcException so that we could use it for similar use cases. Note that we have such exception in Weld too: org.jboss.weld.exceptions.WeldException.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very specific use case, it should not be used for general exceptions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very specific use case, it should not be used for general exceptions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, TBH I don't understand the name - why UndeclaredThrowable? In the linked reproducer the RollbackException is thrown by a JTA interceptor, or? Shouldn't we name it SubclassInvocationException or something like that?

super(cause);
}

public ArcUndeclaredThrowableException() {
super();
}

public ArcUndeclaredThrowableException(String message) {
super(message);
}

public ArcUndeclaredThrowableException(String message, Throwable cause) {
super(message, cause);
}

protected ArcUndeclaredThrowableException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}