This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new d7a9b93772 SonarQube bug fixes
d7a9b93772 is described below
commit d7a9b93772da9fb268db3933c259b628747004ab
Author: James Bognar <[email protected]>
AuthorDate: Thu Feb 5 10:56:42 2026 -0500
SonarQube bug fixes
---
.../juneau/junit/bct/BasicBeanConverter.java | 2 +-
.../apache/juneau/commons/function/Snippet.java | 4 +-
.../org/apache/juneau/commons/utils/Utils.java | 4 +-
.../src/main/java/org/apache/juneau/BeanMap.java | 10 +---
.../java/org/apache/juneau/BeanPropertyMeta.java | 34 +++++------
.../apache/juneau/html/HtmlSerializerSession.java | 6 +-
.../main/java/org/apache/juneau/xml/XmlReader.java | 12 ++--
.../apache/juneau/xml/XmlSerializerSession.java | 10 ++--
.../apache/juneau/rest/client/ResponseHeader.java | 11 +++-
.../org/apache/juneau/rest/client/RestClient.java | 70 ++++++++++++++++------
.../org/apache/juneau/rest/client/RestRequest.java | 39 ++++++++----
.../apache/juneau/rest/client/RestResponse.java | 18 +++---
.../java/org/apache/juneau/rest/RestContext.java | 16 ++---
.../java/org/apache/juneau/rest/RestOpInvoker.java | 4 +-
.../java/org/apache/juneau/rest/RestOpSession.java | 4 +-
.../java/org/apache/juneau/rest/RestSession.java | 4 +-
.../apache/juneau/rest/converter/Traversable.java | 2 +-
.../apache/juneau/rest/rrpc/RrpcRestOpSession.java | 2 +-
.../apache/juneau/rest/servlet/RestServlet.java | 4 +-
19 files changed, 150 insertions(+), 106 deletions(-)
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
index ea416ecbbb..e2c83e4d54 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
@@ -1026,7 +1026,7 @@ public class BasicBeanConverter implements BeanConverter {
private String safeToString(Object o) {
try {
return o.toString();
- } catch (Throwable t) {
+ } catch (Exception t) {
return cns(t) + ": " + t.getMessage();
}
}
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/function/Snippet.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/function/Snippet.java
index e14d081150..6af3ceb4a1 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/function/Snippet.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/function/Snippet.java
@@ -97,7 +97,7 @@ public interface Snippet {
* <jv>snippet</jv>.run(); <jc>// May throw
IllegalArgumentException</jc>
* </p>
*
- * @throws Throwable Any throwable (checked or unchecked).
+ * @throws Exception Any exception (checked or unchecked).
*/
- void run() throws Throwable;
+ void run() throws Exception;
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
index bfa9d3b215..b320a35b11 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
@@ -1878,7 +1878,7 @@ public class Utils {
public static <T> T safeCatch(ThrowingSupplier<T> s,
Function<Throwable,T> exceptionFunction) {
try {
return s.get();
- } catch (Throwable e) {
+ } catch (Exception e) {
return exceptionFunction.apply(e);
}
}
@@ -1944,7 +1944,7 @@ public class Utils {
public static <T> Optional<T> safeOptCatch(ThrowingSupplier<T> s,
Function<Throwable,T> exceptionFunction) {
try {
return opt(s.get());
- } catch (Throwable e) {
+ } catch (Exception e) {
return opt(exceptionFunction.apply(e));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMap.java
index 4a63dd8e14..b0ef3af6c1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMap.java
@@ -245,10 +245,7 @@ public class BeanMap<T> extends AbstractMap<String,Object>
implements Delegate<T
var val = bpm.get(this, null);
if (valueFilter.test(val))
action.apply(bpm,
bpm.getName(), val, null);
- } catch (Error e) {
- // Errors should always be uncaught.
- throw e;
- } catch (Throwable t) {
+ } catch (Exception t) {
action.apply(bpm, bpm.getName(), null,
t);
}
});
@@ -260,10 +257,7 @@ public class BeanMap<T> extends AbstractMap<String,Object>
implements Delegate<T
forEachProperty(x -> ! x.isDyna(), bpm -> {
try {
actions.put(bpm.getName(), new
BeanPropertyValue(bpm, bpm.getName(), bpm.get(this, null), null));
- } catch (Error e) {
- // Errors should always be uncaught.
- throw e;
- } catch (Throwable t) {
+ } catch (Exception t) {
actions.put(bpm.getName(), new
BeanPropertyValue(bpm, bpm.getName(), null, t));
}
});
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index 890c09cbb4..79c421ff89 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -905,16 +905,16 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (bean == null)
return m.propertyCache.get(name);
- return invokeGetter(bean, pName);
+ return invokeGetter(bean, pName);
- } catch (Throwable e) {
- if (bc.isIgnoreInvocationExceptionsOnGetters()) {
- if (rawTypeMeta.isPrimitive())
- return
rawTypeMeta.getPrimitiveDefault();
- return null;
- }
- throw bex(e, beanMeta.getClassMeta(), "Exception
occurred while getting property ''{0}''", name);
+ } catch (Exception e) {
+ if (bc.isIgnoreInvocationExceptionsOnGetters()) {
+ if (rawTypeMeta.isPrimitive())
+ return rawTypeMeta.getPrimitiveDefault();
+ return null;
}
+ throw bex(e, beanMeta.getClassMeta(), "Exception occurred while
getting property ''{0}''", name);
+ }
}
/**
@@ -1219,17 +1219,17 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (bean == null)
return m.propertyCache.get(name);
- var session = m.getBeanSession();
- var o = getRaw(m, pName);
+ var session = m.getBeanSession();
+ var o = getRaw(m, pName);
- return swapAndFilterProperty(session, o);
+ return swapAndFilterProperty(session, o);
- } catch (Throwable e) {
- if (bc.isIgnoreInvocationExceptionsOnGetters()) {
- if (rawTypeMeta.isPrimitive())
- return
rawTypeMeta.getPrimitiveDefault();
- return null;
- }
+ } catch (Exception e) {
+ if (bc.isIgnoreInvocationExceptionsOnGetters()) {
+ if (rawTypeMeta.isPrimitive())
+ return rawTypeMeta.getPrimitiveDefault();
+ return null;
+ }
throw bex(e, beanMeta.getClassMeta(), "Exception
occurred while getting property ''{0}''", name);
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
index f1703f790a..a368e8ebbd 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
@@ -456,9 +456,9 @@ public class HtmlSerializerSession extends
XmlSerializerSession {
out.i(i + 2);
if (nn(link))
out.eTag("a");
- } catch (SerializeException | Error e) {
+ } catch (SerializeException e) {
throw e;
- } catch (Throwable e) {
+ } catch (Exception e) {
onBeanGetterException(pMeta, e);
}
out.eTag("td").nl(i + 2);
@@ -663,7 +663,7 @@ public class HtmlSerializerSession extends
XmlSerializerSession {
value = e.getValue();
} catch (StackOverflowError t) {
throw t;
- } catch (Throwable t) {
+ } catch (Exception t) {
onError(t, "Could not call getValue() on property
''{0}'', {1}", e.getKey(), lm(t));
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
index 18808d555a..8d1d805ccd 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
@@ -70,12 +70,12 @@ public class XmlReader implements XMLStreamReader,
Positionable {
factory.setProperty(XMLInputFactory.RESOLVER,
resolver);
if
(factory.isPropertySupported(XMLInputFactory.ALLOCATOR) && nn(eventAllocator))
factory.setProperty(XMLInputFactory.ALLOCATOR,
eventAllocator);
- sr = factory.createXMLStreamReader(r);
- sr.nextTag();
- pipe.setPositionable(this);
- } catch (Error e) {
- throw castException(IOException.class, e);
- }
+ sr = factory.createXMLStreamReader(r);
+ sr.nextTag();
+ pipe.setPositionable(this);
+ } catch (Exception e) {
+ throw castException(IOException.class, e);
+ }
}
@Override /* Overridden from XMLStreamReader */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
index 5c80cbe7d7..6ee4a11636 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
@@ -652,11 +652,11 @@ public class XmlSerializerSession extends
WriterSerializerSession {
if (nn(ns) && nn(ns.uri))
addNamespace(ns);
- try {
- findNsfMappings(value);
- } catch (@SuppressWarnings("unused")
Throwable x) {
- // Ignore
- }
+ try {
+ findNsfMappings(value);
+ } catch (@SuppressWarnings("unused") Exception
x) {
+ // Ignore
+ }
});
}
}
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
index 0c1b44e380..fffb325257 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
@@ -258,9 +258,14 @@ public class ResponseHeader extends BasicHeader {
cc = ci.getPublicConstructor(x ->
x.hasParameterTypes(String.class, String.class)).orElse(null);
if (nn(cc))
return cc.newInstance(getName(), getValue());
- } catch (Throwable e) {
- if (e instanceof ExecutableException)
- e = e.getCause();
+ } catch (Exception e) {
+ if (e instanceof ExecutableException) {
+ var cause = e.getCause();
+ if (cause instanceof Exception ex)
+ e = ex;
+ else
+ throw toRex(cause);
+ }
throw toRex(e);
}
throw rex("Could not determine a method to construct type {0}",
cn(c));
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 257ef46db8..787eaa6a8b 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -6377,7 +6377,7 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
ExecutorService es = executorService.get();
if (nn(es) && executorServiceShutdownOnClose)
es.shutdown();
- } catch (@SuppressWarnings("unused") Throwable t) {}
+ } catch (@SuppressWarnings("unused") Exception t) {}
if (nn(creationStack))
closedStack = Thread.currentThread().getStackTrace();
}
@@ -7074,21 +7074,19 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
var ror = rom.getReturns();
if (ror.isFuture()) {
- return getExecutorService().submit(()
-> {
- try {
- return
executeRemote(interfaceClass, rc, method, rom);
- } catch (Exception e) {
- throw e;
- } catch (Throwable e) {
- throw toRex(e);
- }
- });
+ return getExecutorService().submit(() -> {
+ try {
+ return
executeRemote(interfaceClass, rc, method, rom);
+ } catch (Exception e) {
+ throw toRex(e);
+ }
+ });
} else if (ror.isCompletableFuture()) {
var cf = new CompletableFuture<>();
getExecutorService().submit(() -> {
try {
cf.complete(executeRemote(interfaceClass, rc, method, rom));
- } catch (Throwable e) {
+ } catch (Exception e) {
cf.completeExceptionally(e);
}
return null;
@@ -7096,7 +7094,21 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
return cf;
}
- return executeRemote(interfaceClass, rc,
method, rom);
+ try {
+ return executeRemote(interfaceClass,
rc, method, rom);
+ } catch (Exception e) {
+ // Check if this is a RuntimeException
wrapping a RestCallException with an Error cause
+ if (e instanceof RuntimeException rex
&& rex.getCause() instanceof RestCallException rce) {
+ var t = rce.getCause();
+ if (nn(t)) {
+ // Check if the cause
matches the method's declared exception types
+ for (var t2 :
method.getExceptionTypes())
+ if
(t2.isInstance(t))
+ throw
t; // Rethrow the original Throwable (can be Error)
+ }
+ }
+ throw e;
+ }
}
});
}
@@ -7226,11 +7238,27 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
v =
ClassInfo.of(method.getReturnType()).getPrimitiveDefault();
return v;
- } catch (Throwable e) {
+ } catch (Exception e) {
+ // Check if this is a RuntimeException
wrapping a RestCallException with an Error cause
+ if (e instanceof RuntimeException rex
&& rex.getCause() instanceof RestCallException rce) {
+ var t = rce.getCause();
+ if (nn(t)) {
+ // Check if the cause
matches the method's declared exception types
+ for (var t2 :
method.getExceptionTypes())
+ if
(t2.isInstance(t))
+ throw
t; // Rethrow the original Throwable (can be Error)
+ }
+ }
if (e instanceof RestCallException e2) {
var t = e2.getCause();
- if (nn(t))
- e = t;
+ if (nn(t)) {
+ // Check if the cause
matches the method's declared exception types
+ for (var t2 :
method.getExceptionTypes())
+ if
(t2.isInstance(t))
+ throw
t; // Rethrow the original Throwable (can be Error)
+ if (t instanceof
Exception ex)
+ e = ex;
+ }
}
if (e instanceof RuntimeException e2)
throw e2;
@@ -8004,7 +8032,7 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
}
@SuppressWarnings("java:S3776")
- Object executeRemote(Class<?> interfaceClass, RestRequest rc, Method
method, RemoteOperationMeta rom) throws Throwable {
+ Object executeRemote(Class<?> interfaceClass, RestRequest rc, Method
method, RemoteOperationMeta rom) throws Exception {
RemoteOperationReturn ror = rom.getReturns();
try {
@@ -8043,9 +8071,13 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
Throwable t = e.getCause();
if (t instanceof RuntimeException t2)
throw t2;
- for (var t3 : method.getExceptionTypes())
- if (t3.isInstance(t))
- throw t;
+ if (t instanceof Exception ex) {
+ for (var t3 : method.getExceptionTypes())
+ if (t3.isInstance(ex))
+ throw ex;
+ }
+ // If cause is an Error that matches method's exception
types, preserve it in RestCallException
+ // The InvocationHandler will unwrap it and rethrow the
original Error
throw toRex(e);
}
}
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
index fbeea51dc1..9f1d533027 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
@@ -343,7 +343,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
if (nn(response)) {
response.close();
}
- } catch (RuntimeException | Error e) {
+ } catch (RuntimeException e) {
// Let unchecked exceptions propagate for debuggability
throw e;
} catch (Exception e) {
@@ -1999,18 +1999,31 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
if (t.getName().equals(className)) {
ConstructorInfo c = null;
var ci = ClassInfo.of(t);
+ Throwable thrownInstance = null;
c = ci.getPublicConstructor(x
-> x.hasParameterTypes(HttpResponse.class)).orElse(null);
- if (nn(c))
- throw
c.<Throwable>newInstance(response);
- c = ci.getPublicConstructor(x
-> x.hasParameterTypes(String.class)).orElse(null);
- if (nn(c))
- throw
c.<Throwable>newInstance(nn(message) ? message :
response.getContent().asString());
- c = ci.getPublicConstructor(x
-> x.hasParameterTypes(String.class, Throwable.class)).orElse(null);
- if (nn(c))
- throw
c.<Throwable>newInstance(nn(message) ? message :
response.getContent().asString(), null);
- c =
ci.getPublicConstructor(cons -> cons.getParameterCount() == 0).orElse(null);
- if (nn(c))
- throw
c.<Throwable>newInstance();
+ if (nn(c)) {
+ thrownInstance =
c.<Throwable>newInstance(response);
+ } else {
+ c =
ci.getPublicConstructor(x -> x.hasParameterTypes(String.class)).orElse(null);
+ if (nn(c)) {
+ thrownInstance
= c.<Throwable>newInstance(nn(message) ? message :
response.getContent().asString());
+ } else {
+ c =
ci.getPublicConstructor(x -> x.hasParameterTypes(String.class,
Throwable.class)).orElse(null);
+ if (nn(c)) {
+
thrownInstance = c.<Throwable>newInstance(nn(message) ? message :
response.getContent().asString(), null);
+ } else {
+ c =
ci.getPublicConstructor(cons -> cons.getParameterCount() == 0).orElse(null);
+ if
(nn(c)) {
+
thrownInstance = c.<Throwable>newInstance();
+ }
+ }
+ }
+ }
+ if (nn(thrownInstance)) {
+ if (thrownInstance
instanceof Exception ex)
+ throw ex;
+ throw new
RestCallException(response, thrownInstance, "Server threw non-Exception: {0}",
className);
+ }
}
}
}
@@ -2024,7 +2037,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
if (nn(response))
response.close();
throw e;
- } catch (Throwable e) {
+ } catch (Exception e) {
if (nn(response))
response.close();
throw new RestCallException(response, e, "Call
failed.");
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestResponse.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestResponse.java
index 7632359927..58b7f04ac2 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestResponse.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestResponse.java
@@ -431,14 +431,14 @@ public class RestResponse implements HttpResponse,
AutoCloseable {
for (var r : request.interceptors) {
invokeInterceptorOnClose(r, request);
}
- client.onCallClose(request, this);
- } catch (RuntimeException | Error e) {
- // Let unchecked exceptions propagate for debuggability
- throw e;
- } catch (Exception e) {
- // Log checked exceptions but don't throw - follows
AutoCloseable best practices
- client.log(Level.WARNING, e, "Error during RestResponse
close");
- }
+ client.onCallClose(request, this);
+ } catch (RuntimeException e) {
+ // Let unchecked exceptions propagate for debuggability
+ throw e;
+ } catch (Exception e) {
+ // Log checked exceptions but don't throw - follows
AutoCloseable best practices
+ client.log(Level.WARNING, e, "Error during RestResponse close");
+ }
}
/**
@@ -468,7 +468,7 @@ public class RestResponse implements HttpResponse,
AutoCloseable {
private void invokeInterceptorOnClose(RestCallInterceptor r,
RestRequest request) throws RestCallException {
try {
r.onClose(request, this);
- } catch (RuntimeException | Error e) {
+ } catch (RuntimeException e) {
// Let unchecked exceptions propagate - these indicate
programming errors that should be visible
throw e;
} catch (Exception e) {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index fab743a4ee..fe97b6b6d1 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -4683,7 +4683,7 @@ public class RestContext extends Context {
} else {
v.get().add(roc);
}
- } catch (Throwable e) {
+ } catch (Exception e) {
throw servletException(e,
"Problem occurred trying to initialize methods on class {0}",
rci.inner().getName());
}
}
@@ -5239,7 +5239,7 @@ public class RestContext extends Context {
return;
}
- } catch (Throwable e) {
+ } catch (Exception e) {
handleError(sb.build(), convertThrowable(e));
}
@@ -5250,7 +5250,7 @@ public class RestContext extends Context {
s.debug(isDebug(s));
startCall(s);
s.run();
- } catch (Throwable e) {
+ } catch (Exception e) {
handleError(s, convertThrowable(e));
} finally {
try {
@@ -6131,9 +6131,9 @@ public class RestContext extends Context {
* Called during a request to invoke all {@link RestPostCall}
methods.
*
* @param session The current request.
- * @throws Throwable If thrown from call methods.
- */
- protected void postCall(RestOpSession session) throws Throwable {
+ * @throws Exception If thrown from call methods.
+ */
+ protected void postCall(RestOpSession session) throws Exception {
for (var m : session.getContext().getPostCallMethods())
m.invoke(session);
}
@@ -6142,9 +6142,9 @@ public class RestContext extends Context {
* Called during a request to invoke all {@link RestPreCall} methods.
*
* @param session The current request.
- * @throws Throwable If thrown from call methods.
+ * @throws Exception If thrown from call methods.
*/
- protected void preCall(RestOpSession session) throws Throwable {
+ protected void preCall(RestOpSession session) throws Exception {
for (var m : session.getContext().getPreCallMethods())
m.invoke(session);
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpInvoker.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpInvoker.java
index ab638f9e35..b37964ff9c 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpInvoker.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpInvoker.java
@@ -52,9 +52,9 @@ public class RestOpInvoker extends MethodInvoker {
* Invokes this method from the specified {@link RestSession}.
*
* @param opSession The REST call.
- * @throws Throwable If an error occurred during either parameter
resolution or method invocation.
+ * @throws Exception If an error occurred during either parameter
resolution or method invocation.
*/
- public void invoke(RestOpSession opSession) throws Throwable {
+ public void invoke(RestOpSession opSession) throws Exception {
var args = new Object[opArgs.length];
for (var i = 0; i < opArgs.length; i++) {
ParameterInfo pi = inner().getParameter(i);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
index 5116fc8f46..93b03070c0 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
@@ -200,9 +200,9 @@ public class RestOpSession extends ContextSession {
* <li>Calls the converters on the Java method.
* </ol>
*
- * @throws Throwable Any throwable can be thrown.
+ * @throws Exception Any exception can be thrown.
*/
- public void run() throws Throwable {
+ public void run() throws Exception {
for (var guard : ctx.getGuards()) {
if (! guard.guard(req, res))
return;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
index 120f160895..4703663727 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
@@ -502,9 +502,9 @@ public class RestSession extends ContextSession {
* <li>If no Java method matched, generates a 404/405/412 by
calling {@link RestContext#handleNotFound(RestSession)}.
* </ol>
*
- * @throws Throwable Any throwable can be thrown.
+ * @throws Exception Any exception can be thrown.
*/
- public void run() throws Throwable {
+ public void run() throws Exception {
try {
opSession =
context.getRestOperations().findOperation(this).createSession(this).build();
context.preCall(opSession);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/converter/Traversable.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/converter/Traversable.java
index a7bd057499..72ac86db7d 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/converter/Traversable.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/converter/Traversable.java
@@ -65,7 +65,7 @@ public class Traversable implements RestConverter {
o = or.get(pathRemainder);
} catch (ObjectRestException e) {
throw new BasicHttpException(e.getStatus(), e);
- } catch (Throwable t) {
+ } catch (Exception t) {
throw new InternalServerError(t);
}
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/rrpc/RrpcRestOpSession.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/rrpc/RrpcRestOpSession.java
index 6377d40e7e..97a84ae476 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/rrpc/RrpcRestOpSession.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/rrpc/RrpcRestOpSession.java
@@ -108,7 +108,7 @@ public class RrpcRestOpSession extends RestOpSession {
@Override
@SuppressWarnings("java:S3776")
- public void run() throws Throwable {
+ public void run() throws Exception {
super.run();
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
index e25e36a7a7..839cf0ae39 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
@@ -152,7 +152,7 @@ public abstract class RestServlet extends HttpServlet {
} catch (BasicHttpException e) {
initException.set(e);
log(SEVERE, e, "Servlet init error on class ''{0}''",
cn(this));
- } catch (Throwable e) {
+ } catch (Exception e) {
initException.set(new InternalServerError(e));
log(SEVERE, e, "Servlet init error on class ''{0}''",
cn(this));
}
@@ -203,7 +203,7 @@ public abstract class RestServlet extends HttpServlet {
"Servlet {0} not initialized.
init(ServletConfig) was not called. This can occur if you've overridden this
method but didn't call super.init(RestConfig).", cn(this));
getContext().execute(this, r1, r2);
- } catch (Throwable e) {
+ } catch (Exception e) {
r2.sendError(SC_INTERNAL_SERVER_ERROR, lm(e));
}
}