[
https://issues.apache.org/jira/browse/DOSGI-254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Panu Hämäläinen updated DOSGI-254:
----------------------------------
Description:
If a remote service interface is composed of an interface hierarchy, the
ServiceInvocationHandler (in org.apache.cxf.dosgi.dsw.handlers package) only
handles correctly the checked exceptions of the interface the service directly
implements (the lowest level interface of the hierarchy). The checked
exceptions of the super-interface methods are thrown as generic
ServiceExceptions (which are RuntimeExceptions).
For example below, the IOException thrown by the throwBaseException method gets
converted to ServiceException while the URISyntaxException thrown by the
throwSubException method remains correctly as URISyntaxException. The service
is exported as a TestSubInterface service.
{code}
public interface TestBaseInterface {
void throwBaseException() throws IOException;
}
public interface TestSubInterface extends TestBaseInterface {
void throwSubException() throws URISyntaxException;
}
public class TestClass implements TestSubInterface {
@Override
public void throwBaseException() throws IOException {
throw new IOException("expected baseinterface exception");
}
@Override
public void throwSubException() throws URISyntaxException {
throw new URISyntaxException("some input", "expected subinterface
exception");
}
}
{code}
I have been using DOSGi 1.7.0 but I also checked version 2.0.0 and
ServiceInvocationHandler (now in org.apache.cxf.dosgi.common.proxy package)
seems the same as in previous releases.
The problem seems to be in ServiceInvocationHandler in the method
{code}
private void introspectType(Class<?> iType) {
for (Method m : iType.getDeclaredMethods()) {
for (Class<?> excType : m.getExceptionTypes()) {
if (Exception.class.isAssignableFrom(excType)) {
List<Class<?>> types = exceptionsMap.get(m);
if (types == null) {
types = new ArrayList<Class<?>>();
exceptionsMap.put(m, types);
}
types.add(excType);
}
}
}
}
{code}
for which the javadocs of iType.getDeclaredMethods() say "Returns an array of
Method objects reflecting all the methods declared by the class or interface
represented by this Class object. This includes public, protected, default
(package) access, and private methods, *but excludes inherited methods*."
was:
If a remote service interface is composed of an interface hierarchy, the
ServiceInvocationHandler (in org.apache.cxf.dosgi.dsw.handlers package) only
handles correctly the checked exceptions of the interface the service directly
implements (the lowest level interface of the hierarchy). The checked
exceptions of the super-interface methods are thrown as generic
ServiceExceptions (which are RuntimeExceptions).
For example below, the IOException thrown by the throwBaseException method gets
converted to ServiceException while the URISyntaxException thrown by the
throwSubException method remains correctly as URISyntaxException. The service
is exported as a TestSubInterface service.
{code}
public interface TestBaseInterface {
void throwBaseException() throws IOException;
}
public interface TestSubInterface extends TestBaseInterface {
void throwSubException() throws URISyntaxException;
}
public class TestClass implements TestSubInterface {
@Override
public void throwBaseException() throws IOException {
throw new IOException("expected baseinterface exception");
}
@Override
public void throwSubException() throws URISyntaxException {
throw new URISyntaxException("some input", "expected subinterface
exception");
}
}
{code}
I have been using DOSGi 1.7.0 but I also checked version 2.0.0 and
ServiceInvocationHandler (now in org.apache.cxf.dosgi.common.proxy package)
seems the same as in previous releases.
> ServiceInvocationHandler does not handle checked super-interface exceptions
> correctly
> -------------------------------------------------------------------------------------
>
> Key: DOSGI-254
> URL: https://issues.apache.org/jira/browse/DOSGI-254
> Project: CXF Distributed OSGi
> Issue Type: Bug
> Components: DSW
> Affects Versions: 2.0.0
> Reporter: Panu Hämäläinen
>
> If a remote service interface is composed of an interface hierarchy, the
> ServiceInvocationHandler (in org.apache.cxf.dosgi.dsw.handlers package) only
> handles correctly the checked exceptions of the interface the service
> directly implements (the lowest level interface of the hierarchy). The
> checked exceptions of the super-interface methods are thrown as generic
> ServiceExceptions (which are RuntimeExceptions).
> For example below, the IOException thrown by the throwBaseException method
> gets converted to ServiceException while the URISyntaxException thrown by the
> throwSubException method remains correctly as URISyntaxException. The service
> is exported as a TestSubInterface service.
> {code}
> public interface TestBaseInterface {
> void throwBaseException() throws IOException;
> }
>
> public interface TestSubInterface extends TestBaseInterface {
> void throwSubException() throws URISyntaxException;
> }
> public class TestClass implements TestSubInterface {
> @Override
> public void throwBaseException() throws IOException {
> throw new IOException("expected baseinterface exception");
> }
> @Override
> public void throwSubException() throws URISyntaxException {
> throw new URISyntaxException("some input", "expected subinterface
> exception");
> }
> }
> {code}
> I have been using DOSGi 1.7.0 but I also checked version 2.0.0 and
> ServiceInvocationHandler (now in org.apache.cxf.dosgi.common.proxy package)
> seems the same as in previous releases.
> The problem seems to be in ServiceInvocationHandler in the method
> {code}
> private void introspectType(Class<?> iType) {
> for (Method m : iType.getDeclaredMethods()) {
> for (Class<?> excType : m.getExceptionTypes()) {
> if (Exception.class.isAssignableFrom(excType)) {
> List<Class<?>> types = exceptionsMap.get(m);
> if (types == null) {
> types = new ArrayList<Class<?>>();
> exceptionsMap.put(m, types);
> }
> types.add(excType);
> }
> }
> }
> }
> {code}
> for which the javadocs of iType.getDeclaredMethods() say "Returns an array
> of Method objects reflecting all the methods declared by the class or
> interface represented by this Class object. This includes public, protected,
> default (package) access, and private methods, *but excludes inherited
> methods*."
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)