From commits-return-19857-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Sun Sep 2 13:48:51 2012 Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-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 CFD36DF42 for ; Sun, 2 Sep 2012 13:48:51 +0000 (UTC) Received: (qmail 98146 invoked by uid 500); 2 Sep 2012 13:48:51 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 98072 invoked by uid 500); 2 Sep 2012 13:48:51 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 98053 invoked by uid 99); 2 Sep 2012 13:48:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Sep 2012 13:48:51 +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; Sun, 02 Sep 2012 13:48:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4DE3A23888E3 for ; Sun, 2 Sep 2012 13:48:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1379967 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java Date: Sun, 02 Sep 2012 13:48:05 -0000 To: commits@activemq.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120902134805.4DE3A23888E3@eris.apache.org> Author: davsclaus Date: Sun Sep 2 13:48:04 2012 New Revision: 1379967 URL: http://svn.apache.org/viewvc?rev=1379967&view=rev Log: AMQ-3797: Avoid adding the same paths to property editor serach path, if for example ActiveMQ is redeployed. Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java?rev=1379967&r1=1379966&r2=1379967&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java Sun Sep 2 13:48:04 2012 @@ -18,26 +18,23 @@ package org.apache.activemq.util; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; -import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; - +import java.util.Set; import javax.net.ssl.SSLServerSocket; import org.apache.activemq.command.ActiveMQDestination; - - - public final class IntrospectionSupport { static { @@ -46,17 +43,19 @@ public final class IntrospectionSupport "org.springframework.beans.propertyeditors", "org.apache.activemq.util" }; synchronized (PropertyEditorManager.class) { - String[] existingSearchPath = PropertyEditorManager.getEditorSearchPath(); - String[] newSearchPath = (String[]) Array.newInstance(String.class, - existingSearchPath.length + additionalPath.length); - System.arraycopy(existingSearchPath, 0, - newSearchPath, 0, - existingSearchPath.length); - System.arraycopy(additionalPath, 0, - newSearchPath, existingSearchPath.length, - additionalPath.length); + List list = new ArrayList(); + list.addAll(Arrays.asList(PropertyEditorManager.getEditorSearchPath())); + + if (!list.contains(additionalPath[0])) { + list.add(additionalPath[0]); + } + if (!list.contains(additionalPath[1])) { + list.add(additionalPath[1]); + } + + String[] newSearchPath = list.toArray(new String[list.size()]); try { - PropertyEditorManager.setEditorSearchPath(newSearchPath); + PropertyEditorManager.setEditorSearchPath(newSearchPath); PropertyEditorManager.registerEditor(String[].class, StringArrayEditor.class); } catch(java.security.AccessControlException ignore) { // we might be in an applet...