Return-Path: Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: (qmail 35145 invoked from network); 12 Aug 2008 08:23:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Aug 2008 08:23:08 -0000 Received: (qmail 93269 invoked by uid 500); 12 Aug 2008 08:23:07 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 93250 invoked by uid 500); 12 Aug 2008 08:23:07 -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 92996 invoked by uid 99); 12 Aug 2008 08:23:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 01:23:06 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 08:22:18 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 16598234C1A8 for ; Tue, 12 Aug 2008 01:22:46 -0700 (PDT) Message-ID: <1049201412.1218529366090.JavaMail.jira@brutus> Date: Tue, 12 Aug 2008 01:22:46 -0700 (PDT) From: "Frank Ittermann (JIRA)" To: issues@cxf.apache.org Subject: [jira] Commented: (CXF-1730) The Exception handling if it is thrown from a RequestHandler is not correct i guess. In-Reply-To: <1989118729.1217525551881.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CXF-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621728#action_12621728 ] Frank Ittermann commented on CXF-1730: -------------------------------------- I tried again and it's not working. But I think we are on the right way. I take a look into the source code and I see they are a misunderstanding. The following line of source code: OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), httpMethod, values, requestContentType, acceptContentTypes); message.getExchange().put(OperationResourceInfo.class, ori); has to be performed before the following loop starts for (ProviderInfo sh : shs) { Response response = sh.getProvider().handleRequest(message, resource); .... } This code snippets are from the JAXRSInInterceptor class. So good luck. > The Exception handling if it is thrown from a RequestHandler is not correct i guess. > ------------------------------------------------------------------------------------ > > Key: CXF-1730 > URL: https://issues.apache.org/jira/browse/CXF-1730 > Project: CXF > Issue Type: Bug > Components: REST > Affects Versions: 2.1.2 > Environment: Windows XP, jdk1.6, Apache Tomcat 6.0.16 > Reporter: Frank Ittermann > > Hello again > i' ve used an implementation of RequestHandler to perform authentication stuff. So > if the Authentication failed a RuntimeException is thrown. I've also wrote a ExceptionMapper implementation to transform occurred Exception into Http Status codes. If the RuntimeException from the Authentication was thrown than this is translated to an HTTP 403 status code. > But this Http status code is not send as response. This sends a 200 status code. After a time of debugging i found the code that is responsible for that. The processResponse method of the org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor work not correct is guess. Because code with the following code block this methods ends. > OperationResourceInfo operation = (OperationResourceInfo)exchange.get(OperationResourceInfo.class > .getName()); > if (operation == null) { > return; > } > because the operation variable is null. The code after this is responsible to but the Response from the ExceptionMapper class into the message object so that i received a 403 http status code. > I've searched the code again and i found the code block how put the OperationResourceInfo into the Exchange object. That is done by the processRequest method of the org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor class. But before the OperationResourceInfo object is putted in the registered ResourceHandler are called see the code block below. > for (ProviderInfo sh : shs) { > Response response = sh.getProvider().handleRequest(message, resource); > if (response != null) { > message.getExchange().put(Response.class, response); > return; > } > } > I guess the code how put in the OperationresourceInfo object could be performed before the RequestHandlers are called maybe? > Or it's forbidden to throw a Runtimeexception inside the RequestHandler ? > I've also tried to return an Response object from the RequestHandler but the effect was the same it never arrives the client. It received also the Response object with http code 200. > The CXF framework is great and very flexible good work. The opportunities to register own code is very great. > Good work. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.