Return-Path: Delivered-To: apmail-openejb-commits-archive@www.apache.org Received: (qmail 90289 invoked from network); 20 Feb 2008 21:26:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Feb 2008 21:26:19 -0000 Received: (qmail 63128 invoked by uid 500); 20 Feb 2008 21:26:13 -0000 Delivered-To: apmail-openejb-commits-archive@openejb.apache.org Received: (qmail 63109 invoked by uid 500); 20 Feb 2008 21:26:13 -0000 Mailing-List: contact commits-help@openejb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openejb.apache.org Delivered-To: mailing list commits@openejb.apache.org Received: (qmail 63096 invoked by uid 99); 20 Feb 2008 21:26:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Feb 2008 13:26:13 -0800 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; Wed, 20 Feb 2008 21:25:48 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7173E234C04D for ; Wed, 20 Feb 2008 13:25:43 -0800 (PST) Message-ID: <1191880154.1203542743463.JavaMail.jira@brutus> Date: Wed, 20 Feb 2008 13:25:43 -0800 (PST) From: "scott selikoff (JIRA)" To: commits@openejb.apache.org Subject: [jira] Updated: (OPENEJB-756) CMP2 Select Generation does not include VOID return type In-Reply-To: <705418477.1203541065255.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/OPENEJB-756?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] scott selikoff updated OPENEJB-756: ----------------------------------- Description: The method Cmp2Generator.createSelectMethod() does not support "none" return type. If an ejb.select method is created with result-type-mapping="none", then the return type will return type will get converted to void. This will throw a non-descriptive NullPointerException on line 778, since the return of Cmp2Generator.Convert.getConversion() will be null. Recommendations: FIX #1: Better error message than NullPointerException A better error message would be appreciated here as is seen in the fromObjectTo() method such as: public static void fromObjectTo(MethodVisitor mv, Class to) { if (to.equals(Object.class)) { // direct assignment will work } else if (!to.isPrimitive()) { mv.visitTypeInsn(CHECKCAST, Type.getInternalName(to)); } else { Convert conversion = getConversion(to); if (conversion == null) throw new NullPointerException("unsupported conversion for EJB select return type " + from.getName()); conversion.objectToPrimitive(mv); } } FIX #2: Add void as a supported type. Also, verify doing so would not be a spec violation. TO REPRODUCE: Create a bean method such as the following: /** * @ejb.transaction * type="Mandatory" * @ejb.select * query="DELETE FROM someSCHEMA as a WHERE a.someId=?1" * result-type-mapping="none" * * @param someId */ public abstract void ejbSelectRemoveById(java.lang.Integer someId) throws FinderException; Disclaimer: I take responsibility in the code sample... I was the one charged with debugging it, not writing it. I understand there are better ways to do this. was: The method Cmp2Generator.createSelectMethod() does not support "none" return type. If an ejb.select method is created with result-type-mapping="none", then the return type will return type will get converted to void. This will throw a non-descriptive NullPointerException on line 778, since the return of Cmp2Generator.Convert.getConversion() will be null. Recommendations: Fix #1: Better error message than NullPointerException A better error message would be appreciated here as is seen in the fromObjectTo() method such as: public static void fromObjectTo(MethodVisitor mv, Class to) { if (to.equals(Object.class)) { // direct assignment will work } else if (!to.isPrimitive()) { mv.visitTypeInsn(CHECKCAST, Type.getInternalName(to)); } else { Convert conversion = getConversion(to); if (conversion == null) throw new NullPointerException("unsupported conversion for EJB select return type " + from.getName()); conversion.objectToPrimitive(mv); } } Fix #2: Add void as a supported type. Also, verify doing so would not be a spec violation. > CMP2 Select Generation does not include VOID return type > -------------------------------------------------------- > > Key: OPENEJB-756 > URL: https://issues.apache.org/jira/browse/OPENEJB-756 > Project: OpenEJB > Issue Type: Bug > Components: cmp2 > Affects Versions: 3.0-beta-2 > Environment: N/A > Reporter: scott selikoff > Priority: Minor > Fix For: 3.0-beta-2 > > Original Estimate: 4h > Remaining Estimate: 4h > > The method Cmp2Generator.createSelectMethod() does not support "none" return type. If an ejb.select method is created with result-type-mapping="none", then the return type will return type will get converted to void. This will throw a non-descriptive NullPointerException on line 778, since the return of Cmp2Generator.Convert.getConversion() will be null. > Recommendations: > FIX #1: Better error message than NullPointerException > A better error message would be appreciated here as is seen in the fromObjectTo() method such as: > public static void fromObjectTo(MethodVisitor mv, Class to) { > if (to.equals(Object.class)) { > // direct assignment will work > } else if (!to.isPrimitive()) { > mv.visitTypeInsn(CHECKCAST, Type.getInternalName(to)); > } else { > Convert conversion = getConversion(to); > if (conversion == null) throw new NullPointerException("unsupported conversion for EJB select return type " + from.getName()); > conversion.objectToPrimitive(mv); > } > } > FIX #2: Add void as a supported type. Also, verify doing so would not be a spec violation. > TO REPRODUCE: Create a bean method such as the following: > /** > * @ejb.transaction > * type="Mandatory" > * @ejb.select > * query="DELETE FROM someSCHEMA as a WHERE a.someId=?1" > * result-type-mapping="none" > * > * @param someId > */ > public abstract void ejbSelectRemoveById(java.lang.Integer someId) throws FinderException; > Disclaimer: I take responsibility in the code sample... I was the one charged with debugging it, not writing it. I understand there are better ways to do this. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.