Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 61698 invoked from network); 21 Nov 2008 21:30:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2008 21:30:05 -0000 Received: (qmail 40250 invoked by uid 500); 21 Nov 2008 21:30:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 40219 invoked by uid 500); 21 Nov 2008 21:30:14 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 40039 invoked by uid 99); 21 Nov 2008 21:30:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Nov 2008 13:30:14 -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; Fri, 21 Nov 2008 21:28:58 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 39D6C234C256 for ; Fri, 21 Nov 2008 13:29:44 -0800 (PST) Message-ID: <1150708814.1227302984225.JavaMail.jira@brutus> Date: Fri, 21 Nov 2008 13:29:44 -0800 (PST) From: "Michael Dick (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Assigned: (OPENJPA-780) code review for DistributedStoreManager In-Reply-To: <1885329924.1227240404252.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/OPENJPA-780?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michael Dick reassigned OPENJPA-780: ------------------------------------ Assignee: Michael Dick > code review for DistributedStoreManager > --------------------------------------- > > Key: OPENJPA-780 > URL: https://issues.apache.org/jira/browse/OPENJPA-780 > Project: OpenJPA > Issue Type: Improvement > Components: jdbc > Affects Versions: 1.2.0 > Reporter: Fernando > Assignee: Michael Dick > Priority: Minor > Fix For: 1.3.0, 2.0.0 > > > I am currently reviewing code, and this one piece of code stood out. It might not be a bad thing, but it just has a "funny smell". This is in DistributedStoreManager. There it gets a String[], which it then iterates over it to find an appropriate slice. But it looks like it either finds a slice and returns it, or finds a null and throws an exception, all on the first step of the for loop. So really, there is no for loop at all. This might be on purpose, but the code is just not as legible.. > ORIGINAL > /** > * Selects child StoreManager(s) where the given instance resides. > */ > private StoreManager selectStore(OpenJPAStateManager sm, Object edata) { > String[] targets = findSliceNames(sm, edata); > for (String target : targets) { > SliceStoreManager slice = lookup(target); > if (slice == null) > throw new InternalException(_loc.get("wrong-slice", target, sm)); > return slice; > } > return null; > } > expecting more like: > String[] targets = .... > if ( targets == null || targets.length == 0 ) { > return null; > } > SliceStoreManager slice = lookup(targets[0]); > if (slice == null) { > throw new InternalException(_loc.get("wrong-slice", target, sm)); > } > return slice; -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.