[jboss-cvs] JBossAS SVN: r110387 - in trunk: server/src/main/java/org/jboss/as/naming/javaee and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 17 08:04:48 EST 2011


Author: wolfc
Date: 2011-01-17 08:04:47 -0500 (Mon, 17 Jan 2011)
New Revision: 110387

Added:
   trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEUtil.java
Modified:
   trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBossASKernel.java
   trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEApplicationInformer.java
   trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEModuleInformer.java
Log:
JBAS-8669: prevent StringIndexOutOfBoundsException and only cut when there is a typical extension


Modified: trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBossASKernel.java
===================================================================
--- trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBossASKernel.java	2011-01-17 11:46:25 UTC (rev 110386)
+++ trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBossASKernel.java	2011-01-17 13:04:47 UTC (rev 110387)
@@ -61,6 +61,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.jboss.as.naming.javaee.NamingJavaEEUtil.stripSuffix;
+
 /**
  * The JBossAS implementation of the ejb3 KernelAbstraction integration api
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
@@ -228,13 +230,6 @@
       }
    }
 
-   private static String stripSuffix(String s)
-   {
-      if(s == null || s.length() < 4)
-         return s;
-      return s.substring(0, s.length() - 4);
-   }
-
    public void uninstall(String name)
    {
       

Modified: trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEApplicationInformer.java
===================================================================
--- trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEApplicationInformer.java	2011-01-17 11:46:25 UTC (rev 110386)
+++ trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEApplicationInformer.java	2011-01-17 13:04:47 UTC (rev 110387)
@@ -7,6 +7,8 @@
 import org.jboss.reloaded.naming.deployers.javaee.JavaEEApplicationInformer;
 import org.jboss.system.metadata.ServiceDeployment;
 
+import static org.jboss.as.naming.javaee.NamingJavaEEUtil.stripSuffix;
+
 /**
  * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
  */
@@ -27,7 +29,9 @@
       }
       
       String name = deploymentUnit.getSimpleName();
-      return name.substring(0, name.length() - 4);
+      
+      // prevent StringIndexOutOfBoundsException and only cut when there is a typical extension
+      return stripSuffix(name);
    }
 
    public boolean isEnterpriseApplicationArchive(DeploymentUnit deploymentUnit)

Modified: trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEModuleInformer.java
===================================================================
--- trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEModuleInformer.java	2011-01-17 11:46:25 UTC (rev 110386)
+++ trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEModuleInformer.java	2011-01-17 13:04:47 UTC (rev 110387)
@@ -21,12 +21,14 @@
  */
 package org.jboss.as.naming.javaee;
 
-import java.lang.reflect.Array;
-
 import org.jboss.as.javaee.SimpleJavaEEModuleIdentifier;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.reloaded.naming.deployers.javaee.JavaEEModuleInformer;
 
+import java.lang.reflect.Array;
+
+import static org.jboss.as.naming.javaee.NamingJavaEEUtil.stripSuffix;
+
 /**
  * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
  */
@@ -74,7 +76,7 @@
       String path = deploymentUnit.getRelativePath();
       if(path == null || path.length() == 0)
          path = deploymentUnit.getSimpleName();
-      return path.substring(0, path.length() - 4);
+      return stripSuffix(path);
    }
 
    public ModuleType getModuleType(DeploymentUnit deploymentUnit)

Added: trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEUtil.java
===================================================================
--- trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEUtil.java	                        (rev 0)
+++ trunk/server/src/main/java/org/jboss/as/naming/javaee/NamingJavaEEUtil.java	2011-01-17 13:04:47 UTC (rev 110387)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.naming.javaee;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class NamingJavaEEUtil
+{
+   public static String stripSuffix(String s)
+   {
+      int i;
+      if(s == null || (i = s.lastIndexOf('.')) == -1)
+         return s;
+      return s.substring(0, i);
+   }
+}



More information about the jboss-cvs-commits mailing list