jsr345-experts@ejb-spec.java.net

[jsr345-experts] Proposed changes to the Interceptor spec for the throws Exception clause in interceptor method signatures

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Sun, 03 Feb 2013 22:19:05 -0800

If you want to see the proposed changes, scroll down to the "PROPOSED
CHANGES" section. If you want to read how the proposed changes came
about, read it all.

WHAT's WRONG?
The interceptors spec contradicts itself when describing an interceptor
method exceptions rules and defining the interceptor method:

A. The Interceptors spec restrictions on exceptions that can be thrown
by an interceptor method:

2.4Exceptions
"Interceptor methods are allowed to throw runtime exceptions or any
checked exceptions that the associated target method allows within its
throws clause.
Interceptor methods are allowed to catch and suppress exceptions and to
recover by calling the theInvocationContext.proceed method."

B. The EJB spec requirements on the timeout method:
13.2.5.3Timeout Callback Method Requirements

void <METHOD>()
void <METHOD>(Timer timer)

"Timeout callback methods must not throw application exceptions."

C. The interceptor spec requirements on around-invoke and around-timeout
method signatures

2.5Business Method Interceptors

Object <METHOD>(InvocationContext) throws Exception

2.7Timeout Method Interceptors

Object <METHOD>(InvocationContext) throws Exception

============

As you can see, not only the around-timeout returns a value that the
method it interposes on doesn't, but it also must declare the "throws
Exception" clause while the target instance method can only throw
RuntimeException's.

The around-invoke requirement to declare "throws Exception" does not
allow to be more specific.
=============

PROPOSED CHANGES

There are 2 ways to fix the problem. Unless I hear an overwhelming
support for #1, and overwhelming rejection of both options (#3), I'll go
with option #2 to reduce the amount of changes in this version of the
Interceptors spec.

#1
- Change method signatures for both around-invoke to make throws clause
optional:
Object <METHOD>(InvocationContext) [throws Exception]

- Add a note to for the above:
"An around-invoke interceptor method may declare to throw any checked
exceptions that the associated target method allows within its throws
clause. It may declare to throw a java.lang.Exception if it interposes
on several methods that can throw unrelated checked exception."

- Remove "throws Exception" clause from the around-timeout method

#2
- Add a note under the around-invoke method signature:
"An around-invoke interceptor method may declare to throw any checked
exceptions that the associated target method allows within its throws
clause. It may declare to throw the java.lang.Exception if it interposes
on several methods that can throw unrelated checked exception."

- Add a note under the around-timeout method signature:
"An around-timeout interceptor method must not throw application
exceptions, but it may declare to throw checked exceptions or the
java.lang.Exception if the same interceptor method interposes on
business methods in addition to the timeout methods."

#3
The proposed changes do not make any sense

thanks,
-marina