Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CAF04200C02 for ; Fri, 20 Jan 2017 12:58:31 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C9727160B48; Fri, 20 Jan 2017 11:58:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C3A7C160B39 for ; Fri, 20 Jan 2017 12:58:30 +0100 (CET) Received: (qmail 90611 invoked by uid 500); 20 Jan 2017 11:58:30 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 90600 invoked by uid 99); 20 Jan 2017 11:58:29 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jan 2017 11:58:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 5E696C0D33 for ; Fri, 20 Jan 2017 11:58:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 7Cqf7WWAxI7y for ; Fri, 20 Jan 2017 11:58:27 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 61F6E5FBD1 for ; Fri, 20 Jan 2017 11:58:27 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B9671E0046 for ; Fri, 20 Jan 2017 11:58:26 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 706BC20D39 for ; Fri, 20 Jan 2017 11:58:26 +0000 (UTC) Date: Fri, 20 Jan 2017 11:58:26 +0000 (UTC) From: =?utf-8?Q?Panu_H=C3=A4m=C3=A4l=C3=A4inen_=28JIRA=29?= To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DOSGI-254) ServiceInvocationHandler does not handle checked super-interface exceptions correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 20 Jan 2017 11:58:32 -0000 [ https://issues.apache.org/jira/browse/DOSGI-254?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:all-tabpanel ] Panu H=C3=A4m=C3=A4l=C3=A4inen updated DOSGI-254: ---------------------------------- Description:=20 If a remote service interface is composed of an interface hierarchy, the Se= rviceInvocationHandler (in org.apache.cxf.dosgi.dsw.handlers package) only= handles correctly the checked exceptions of the interface the service dire= ctly implements (the lowest level interface of the hierarchy). The checked = exceptions of the super-interface methods are thrown as generic ServiceExce= ptions (which are RuntimeExceptions).=20 For example below, the IOException thrown by the throwBaseException method = gets converted to ServiceException while the URISyntaxException thrown by t= he throwSubException method remains correctly as URISyntaxException. The se= rvice is exported as a TestSubInterface service. {code} public interface TestBaseInterface { void throwBaseException() throws IOException; } =20 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 subinterfa= ce exception"); } } {code} I have been using DOSGi 1.7.0 but I also checked version 2.0.0 and ServiceI= nvocationHandler (now in org.apache.cxf.dosgi.common.proxy package) seems t= he 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> types =3D exceptionsMap.get(m); if (types =3D=3D null) { types =3D new ArrayList>(); 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 inte= rface represented by this Class object. This includes public, protected, de= fault (package) access, and private methods, *but excludes inherited method= s*." was: If a remote service interface is composed of an interface hierarchy, the Se= rviceInvocationHandler (in org.apache.cxf.dosgi.dsw.handlers package) only= handles correctly the checked exceptions of the interface the service dire= ctly implements (the lowest level interface of the hierarchy). The checked = exceptions of the super-interface methods are thrown as generic ServiceExce= ptions (which are RuntimeExceptions).=20 For example below, the IOException thrown by the throwBaseException method = gets converted to ServiceException while the URISyntaxException thrown by t= he throwSubException method remains correctly as URISyntaxException. The se= rvice is exported as a TestSubInterface service. {code} public interface TestBaseInterface { void throwBaseException() throws IOException; } =20 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 subinterfa= ce exception"); } } {code} I have been using DOSGi 1.7.0 but I also checked version 2.0.0 and ServiceI= nvocationHandler (now in org.apache.cxf.dosgi.common.proxy package) seems t= he same as in previous releases. > ServiceInvocationHandler does not handle checked super-interface exceptio= ns 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=C3=A4m=C3=A4l=C3=A4inen > > If a remote service interface is composed of an interface hierarchy, the = ServiceInvocationHandler (in org.apache.cxf.dosgi.dsw.handlers package) on= ly handles correctly the checked exceptions of the interface the service di= rectly implements (the lowest level interface of the hierarchy). The checke= d exceptions of the super-interface methods are thrown as generic ServiceEx= ceptions (which are RuntimeExceptions).=20 > For example below, the IOException thrown by the throwBaseException metho= d 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; > } > =20 > 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 subinter= face exception"); > } > } > {code} > I have been using DOSGi 1.7.0 but I also checked version 2.0.0 and Servic= eInvocationHandler (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> types =3D exceptionsMap.get(m); > if (types =3D=3D null) { > types =3D new ArrayList>(); > exceptionsMap.put(m, types); > } > types.add(excType); > } > } > } > } > {code} > for which the javadocs of iType.getDeclaredMethods() say "Returns an arr= ay of Method objects reflecting all the methods declared by the class or in= terface represented by this Class object. This includes public, protected, = default (package) access, and private methods, *but excludes inherited meth= ods*." -- This message was sent by Atlassian JIRA (v6.3.4#6332)