Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 72680 invoked from network); 16 Oct 2008 19:50:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Oct 2008 19:50:59 -0000 Received: (qmail 49575 invoked by uid 500); 16 Oct 2008 19:50:59 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 49539 invoked by uid 500); 16 Oct 2008 19:50:59 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 49528 invoked by uid 99); 16 Oct 2008 19:50:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Oct 2008 12:50:59 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simon.lessard.3@gmail.com designates 209.85.217.20 as permitted sender) Received: from [209.85.217.20] (HELO mail-gx0-f20.google.com) (209.85.217.20) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Oct 2008 19:49:53 +0000 Received: by gxk13 with SMTP id 13so162407gxk.12 for ; Thu, 16 Oct 2008 12:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=5szkzILdzyjBzG8R67uzWe1sTq1b2YfrkTeB1RsDyVQ=; b=Q1kzAHq/gyGGeUmewPxiEEcpze9B71naDX57rRhSaBWUDr8LDH/0dHSANEuHFErvtZ FHrFLSN7YbPOVsmysY5zu1UDMK1W+MDPQ56CKWPeJ2x48F2ehTo5JOvPfsmuJSWiZoOI KlvjiPM0LgpbQxdyjrVq6XT+ULPH0unmQKhKM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=qdkt4w7gysvkXm6UoRSZsFWf8Ts6alkrn8DXSecE3cmK5L9cdMrmkoibYTXHynrbua PnH0MkDDE15+2BYekCsdGH3lr6Dx310LVnwf7asSENtZm4J+75RAu5Vu9ptdaF2zPyMO AJQLbBv+6haZ6ChG3dtr0gi63r+12TjH+KgCU= Received: by 10.100.254.15 with SMTP id b15mr4189524ani.35.1224186630748; Thu, 16 Oct 2008 12:50:30 -0700 (PDT) Received: by 10.100.7.15 with HTTP; Thu, 16 Oct 2008 12:50:30 -0700 (PDT) Message-ID: <254acf980810161250u1466df30h5487ac172b810fe3@mail.gmail.com> Date: Thu, 16 Oct 2008 15:50:30 -0400 From: "Simon Lessard" To: MyFaces-Devs Subject: [TRINIDAD] Shallowed ClassCastException in SortableModel MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_20790_4196253.1224186630753" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_20790_4196253.1224186630753 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, I'm working on an ADF Faces Rich Client atm and as some may know, that library is based on Trinidad. Anyway, while debugging for a completely different issue, I found out the following in SortableModel class: private int _toRowIndex(Object rowKey) { if (rowKey == null) return -1; try { return ((Integer)rowKey).intValue(); } catch (ClassCastException e) { _LOG.warning("INVALID_ROWKEY", new Object[]{rowKey , rowKey.getClass()}); _LOG.warning(e); return -1; } } I think we should change that to something like the following to not shallow an Exception that's more expensive to create than an instanceof check. Note that for some reason I get one such exception per request currently so this is kind of annoying ;) : private int _toRowIndex(Object rowKey) { if (rowKey == null) { return -1; } else if (rowKey instanceof Integer) { return ((Integer)rowKey).intValue(); } else { _LOG.warning("INVALID_ROWKEY", new Object[]{rowKey , rowKey.getClass()}); return -1; } } What do you think? ~ Simon ------=_Part_20790_4196253.1224186630753 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hi all,

I'm working on an ADF Faces Rich Client atm and as some may know, that library is based on Trinidad. Anyway, while debugging for a completely different issue, I found out the following in SortableModel class:

private int _toRowIndex(Object rowKey)
{
    if (rowKey == null)
        return -1;

    try
    {
        return ((Integer)rowKey).intValue();
    }
    catch (ClassCastException e)
    {
        _LOG.warning("INVALID_ROWKEY", new Object[]{rowKey , rowKey.getClass()});
        _LOG.warning(e);
        return -1;
    }
}

I think we should change that to something like the following to not shallow an Exception that's more expensive to create than an instanceof check. Note that for some reason I get one such exception per request currently so this is kind of annoying ;) :

private int _toRowIndex(Object rowKey)
{
    if (rowKey == null)
    {
        return -1;
    }
    else if (rowKey instanceof Integer)
    {
       
return ((Integer)rowKey).intValue();
    }
    else
    {
        _LOG.warning("INVALID_ROWKEY", new Object[]{rowKey , rowKey.getClass()});
        return -1;
    }
}

What do you think?


~ Simon
------=_Part_20790_4196253.1224186630753--