Skip to content

Commit

Permalink
WELD-2762 Do not swallow exceptions occuring during HTTP session crea…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
manovotn committed Oct 18, 2023
1 parent cb0b1f7 commit 28381ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Expand Up @@ -89,5 +89,4 @@ public static void rethrowException(NoSuchMethodException e, Class<? extends Run
public static void rethrowException(InvocationTargetException e) {
rethrowException(e.getCause() != null ? e.getCause() : e);
}

}
Expand Up @@ -16,6 +16,7 @@
*/
package org.jboss.weld.security;

import java.lang.reflect.InvocationTargetException;
import java.security.PrivilegedExceptionAction;

public class NewInstanceAction<T> extends AbstractGenericReflectionAction<T> implements PrivilegedExceptionAction<T> {
Expand All @@ -29,7 +30,7 @@ public NewInstanceAction(Class<T> javaClass) {
}

@Override
public T run() throws InstantiationException, IllegalAccessException {
return javaClass.newInstance();
public T run() throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
return javaClass.getDeclaredConstructor().newInstance();
}
}
Expand Up @@ -85,10 +85,10 @@ protected HttpSession getSession(boolean create) {
try {
return SessionHolder.getSession(request, create);
} catch (IllegalStateException e) {
// If container can't create an underlying session, invalidate the
// current one
// If container can't create an underlying session, invalidate the current one
detach();
return null;
// re-throw the exception to properly show cause and message
throw e;
}
}

Expand Down

0 comments on commit 28381ea

Please sign in to comment.