Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2E60D917A for ; Tue, 12 Jun 2012 19:48:28 +0000 (UTC) Received: (qmail 75040 invoked by uid 500); 12 Jun 2012 19:48:28 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 75013 invoked by uid 500); 12 Jun 2012 19:48:28 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 75006 invoked by uid 99); 12 Jun 2012 19:48:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jun 2012 19:48:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jun 2012 19:48:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AE4CD238899C for ; Tue, 12 Jun 2012 19:48:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1349496 - /felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java Date: Tue, 12 Jun 2012 19:48:06 -0000 To: commits@felix.apache.org From: clement@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120612194806.AE4CD238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: clement Date: Tue Jun 12 19:48:06 2012 New Revision: 1349496 URL: http://svn.apache.org/viewvc?rev=1349496&view=rev Log: Fixed FELIX-3500 Improve the implementation of the method id computation. Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java?rev=1349496&r1=1349495&r2=1349496&view=diff ============================================================================== --- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java (original) +++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java Tue Jun 12 19:48:06 2012 @@ -23,12 +23,7 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Member; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Dictionary; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import org.apache.felix.ipojo.architecture.InstanceDescription; import org.apache.felix.ipojo.metadata.Element; @@ -152,7 +147,7 @@ public class InstanceManager implements * The Map storing the Method objects by ids. * [id=>{@link Method}]. */ - private Map m_methods = new HashMap(); + private Map m_methods = new Hashtable(); /** @@ -1155,15 +1150,13 @@ public class InstanceManager implements * @return the method object or null if the method cannot be found. */ private Member getMethodById(String methodId) { - // Not necessary synchronized as recomputing the methodID will give the same Method twice. + // Used a synchronized map. Member member = (Member) m_methods.get(methodId); if (member == null && m_clazz != null) { - // First try on methods. Method[] mets = m_clazz.getDeclaredMethods(); for (int i = 0; i < mets.length; i++) { - // Check if the method was not already computed. If not, compute the Id and check. - if (!m_methods.containsValue(mets[i]) && (MethodMetadata.computeMethodId(mets[i]).equals(methodId))) { + if (MethodMetadata.computeMethodId(mets[i]).equals(methodId)) { // Store the new methodId m_methods.put(methodId, mets[i]); return mets[i]; @@ -1175,7 +1168,7 @@ public class InstanceManager implements Constructor[] constructors = m_clazz.getDeclaredConstructors(); for (int i = 0; i < constructors.length; i++) { // Check if the constructor was not already computed. If not, compute the Id and check. - if (!m_methods.containsValue(constructors[i]) && (MethodMetadata.computeMethodId(constructors[i]).equals(methodId))) { + if (MethodMetadata.computeMethodId(constructors[i]).equals(methodId)) { // Store the new methodId m_methods.put(methodId, constructors[i]); return constructors[i]; @@ -1183,7 +1176,7 @@ public class InstanceManager implements } } - // Cannot happen + // Should not happen m_logger.log(Logger.INFO, "A methodID cannot be associated with a method from the POJO class: " + methodId); return null; } else {