[jboss-svn-commits] JBoss Portal SVN: r5250 - in trunk: cms/src/main/org/jboss/portal/cms/hibernate cms/src/main/org/jboss/portal/test/cms/commands common common/src/main/org/jboss/portal/common/ant common/src/main/org/jboss/portal/common/util common/src/main/org/jboss/portal/test/common core/src/main/org/jboss/portal/core/cms/servlet core/src/main/org/jboss/portal/core/deployment/jboss core/src/main/org/jboss/portal/test/core portlet/src/main/org/jboss/portal/portlet/deployment/jboss server/src/main/org/jboss/portal/server/deployment test/src/main/org/jboss/portal/test/framework/embedded theme/src/main/org/jboss/portal/theme/deployment/jboss tools/lib wsrp/src/main/org/jboss/portal/wsrp/services

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 25 17:27:55 EDT 2006


Author: julien at jboss.com
Date: 2006-09-25 17:27:23 -0400 (Mon, 25 Sep 2006)
New Revision: 5250

Added:
   trunk/common/src/main/org/jboss/portal/test/common/BufferedStreamTestCase.java
Modified:
   trunk/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java
   trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
   trunk/common/build.xml
   trunk/common/src/main/org/jboss/portal/common/ant/Explode.java
   trunk/common/src/main/org/jboss/portal/common/ant/Implode.java
   trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
   trunk/common/src/main/org/jboss/portal/common/util/Tools.java
   trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java
   trunk/core/src/main/org/jboss/portal/core/cms/servlet/CMSExportServlet.java
   trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
   trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
   trunk/core/src/main/org/jboss/portal/test/core/Utils.java
   trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
   trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java
   trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java
   trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
   trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutDeployment.java
   trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutFeaturesDeployment.java
   trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/ThemeDeployment.java
   trunk/tools/lib/explode.jar
   trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
wrap with buffered input/output stream where it make sense

Modified: trunk/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/cms/src/main/org/jboss/portal/cms/hibernate/HibernateStore.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -31,6 +31,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.RandomAccessFile;
+import java.io.BufferedInputStream;
 import java.sql.Blob;
 import java.util.Iterator;
 import java.util.List;
@@ -959,7 +960,7 @@
                      try
                      {
                         long length = f.length();
-                        in = new FileInputStream(f);
+                        in = Tools.safeBufferedWrapper(new FileInputStream(f));
                         if(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
                         {
                            Query query = session.createQuery("from VersionEntry where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
@@ -1168,7 +1169,7 @@
                      try
                      {
                         long length = f.length();
-                        in = new FileInputStream(f);
+                        in = Tools.safeBufferedWrapper(new FileInputStream(f));
                         if(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
                         {
                            Query query = session.createQuery("from VersionEntry where FSENTRY_PATH = ? and FSENTRY_NAME = ? and FSENTRY_DATA is not null");
@@ -1242,7 +1243,7 @@
                      try
                      {
                         long length = f.length();
-                        in = new FileInputStream(f);
+                        in = Tools.safeBufferedWrapper(new FileInputStream(f));
                         if(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
                         {
                            VersionEntry versionEntry = new VersionEntry(parentDir, name, createBlob(in), System.currentTimeMillis(), length);

Modified: trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -25,10 +25,12 @@
 import org.jboss.portal.cms.CMSException;
 import org.jboss.portal.cms.Command;
 import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.common.util.Tools;
 
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.BufferedInputStream;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -76,7 +78,7 @@
    public void testArchiveUpload() throws CMSException, IOException
    {
       service.setDefaultLocale(Locale.ENGLISH.getLanguage());
-      InputStream is = new FileInputStream(sZipFile);
+      InputStream is = Tools.safeBufferedWrapper(new FileInputStream(sZipFile));
       Command storearchiveCMD = service.getCommandFactory().createStoreArchiveCommand("", is, "en");
       List contentsToVersion = (List) service.execute(storearchiveCMD);
 

Modified: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/build.xml	2006-09-25 21:27:23 UTC (rev 5250)
@@ -203,6 +203,7 @@
             <test todir="${test.reports}" name="org.jboss.portal.test.common.LocalizedStringTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.common.ImplodeTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.common.Application_XWWWFormURLEncodedFormatTestCase"/>
+            <test todir="${test.reports}" name="org.jboss.portal.test.common.BufferedStreamTestCase"/>
          </x-test>
          <x-classpath>
             <pathelement location="${build.classes}"/>

Modified: trunk/common/src/main/org/jboss/portal/common/ant/Explode.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/ant/Explode.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/src/main/org/jboss/portal/common/ant/Explode.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -23,6 +23,7 @@
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
+import org.jboss.portal.common.util.Tools;
 
 import java.io.*;
 import java.util.Arrays;
@@ -112,11 +113,10 @@
       {
          name = file.getName();
       }
-      InputStream in = null;
+      ZipInputStream zip = null;
       try
       {
-         in = new FileInputStream(file);
-         ZipInputStream zip = new ZipInputStream(in);
+         zip = new ZipInputStream(Tools.safeBufferedWrapper(new FileInputStream(file)));
          log("Process archive " + name);
          explode(this, name, zip, todir, this.exclude);
       }
@@ -126,11 +126,11 @@
       }
       finally
       {
-         if(in != null)
+         if(zip != null)
          {
             try
             {
-               in.close();
+               zip.close();
             }
             catch(IOException ignored)
             {
@@ -209,10 +209,10 @@
             else
             {
                // This is a file we write it
-               FileOutputStream out = null;
+               OutputStream out = null;
                try
                {
-                  out = new FileOutputStream(fic);
+                  out = Tools.safeBufferedWrapper(new FileOutputStream(fic));
                   for(int size = zip.read(buffer); size != -1; size = zip.read(buffer))
                   {
                      out.write(buffer, 0, size);

Modified: trunk/common/src/main/org/jboss/portal/common/ant/Implode.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/ant/Implode.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/src/main/org/jboss/portal/common/ant/Implode.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -23,6 +23,7 @@
 
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.BuildException;
+import org.jboss.portal.common.util.Tools;
 
 import java.util.Set;
 import java.util.HashSet;
@@ -34,6 +35,10 @@
 import java.io.IOException;
 import java.io.ByteArrayOutputStream;
 import java.io.FileOutputStream;
+import java.io.BufferedOutputStream;
+import java.io.OutputStream;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -92,11 +97,11 @@
       //if (tofile == null || tofile.lastModified() < dir.lastModified())
 
 
-      FileOutputStream out = null;
+      OutputStream out = null;
       try
       {
          byte[] bytes = implode(dir);
-         out = new FileOutputStream(tofile);
+         out = Tools.safeBufferedWrapper(new FileOutputStream(tofile));
          out.write(bytes);
       }
       catch (IOException e)
@@ -133,10 +138,10 @@
    {
       if (f.isFile())
       {
-         FileInputStream in = null;
+         InputStream in = null;
          try
          {
-            in = new FileInputStream(f);
+            in = Tools.safeBufferedWrapper(new FileInputStream(f));
             byte[] bytes = new byte[1024];
 
             //

Modified: trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -71,7 +71,7 @@
       InputStream in = null;
       try
       {
-         in = asInputStream();
+         in = Tools.safeBufferedWrapper(asInputStream());
          return builder.parse(in);
       }
       catch (SAXException e)
@@ -106,7 +106,7 @@
       InputStream in = null;
       try
       {
-         in = asInputStream();
+         in = Tools.safeBufferedWrapper(asInputStream());
          Properties props = new Properties();
          if (xml)
          {
@@ -159,7 +159,7 @@
       InputStream in = null;
       try
       {
-         in = asInputStream();
+         in = Tools.safeBufferedWrapper(asInputStream());
          ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
          Tools.copy(in, out);
          if (enc == null)

Modified: trunk/common/src/main/org/jboss/portal/common/util/Tools.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/Tools.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/src/main/org/jboss/portal/common/util/Tools.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -37,6 +37,8 @@
 import java.io.Serializable;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -802,4 +804,42 @@
       ObjectInputStream ois = new ObjectInputStream(bais);
       return (Serializable)ois.readObject();
    }
+
+   public static BufferedInputStream safeBufferedWrapper(InputStream in)
+   {
+      if (in != null)
+      {
+         if (in instanceof BufferedInputStream)
+         {
+            return (BufferedInputStream)in;
+         }
+         else
+         {
+            return new BufferedInputStream(in);
+         }
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   public static BufferedOutputStream safeBufferedWrapper(OutputStream out)
+   {
+      if (out != null)
+      {
+         if (out instanceof BufferedOutputStream)
+         {
+            return (BufferedOutputStream)out;
+         }
+         else
+         {
+            return new BufferedOutputStream(out);
+         }
+      }
+      else
+      {
+         return null;
+      }
+   }
 }
\ No newline at end of file

Added: trunk/common/src/main/org/jboss/portal/test/common/BufferedStreamTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/BufferedStreamTestCase.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/src/main/org/jboss/portal/test/common/BufferedStreamTestCase.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.BufferedInputStream;
+import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedOutputStream;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BufferedStreamTestCase extends TestCase
+{
+
+   public BufferedStreamTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testInputStream() throws Exception
+   {
+      assertNull(Tools.safeBufferedWrapper((InputStream)null));
+      BufferedInputStream in = Tools.safeBufferedWrapper(new ByteArrayInputStream("abc".getBytes("UTF8")));
+      assertEquals(System.identityHashCode(in), System.identityHashCode(Tools.safeBufferedWrapper(in)));
+      assertNotNull(in);
+      byte[] bytes = "abc".getBytes("UTF8");
+      Arrays.fill(bytes, (byte)0);
+      assertEquals(bytes.length, in.read(bytes));
+      assertEquals(-1, in.read());
+      assertEquals("abc", new String(bytes, "UTF8"));
+   }
+
+   public void testOutputputStream() throws Exception
+   {
+      assertNull(Tools.safeBufferedWrapper((OutputStream)null));
+      ByteArrayOutputStream out = new ByteArrayOutputStream();
+      BufferedOutputStream buffered = Tools.safeBufferedWrapper(out);
+      assertNotNull(buffered);
+      assertEquals(System.identityHashCode(buffered), System.identityHashCode(Tools.safeBufferedWrapper(buffered)));
+      buffered.write("abc".getBytes("UTF8"));
+      buffered.close();
+      assertEquals("abc", out.toString("UTF8"));
+   }
+}

Modified: trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/common/src/main/org/jboss/portal/test/common/JarTestCase.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -32,8 +32,12 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedInputStream;
 
 import org.jboss.portal.common.util.Jar;
+import org.jboss.portal.common.util.Tools;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -81,7 +85,7 @@
    {
       File jarFile = File.createTempFile("test", ".jar");
 
-      FileOutputStream out = new FileOutputStream(jarFile);
+      OutputStream out = Tools.safeBufferedWrapper(new FileOutputStream(jarFile));
       JarOutputStream jarOut = new JarOutputStream(out);
       jarOut.putNextEntry(new JarEntry("a/c"));
       jarOut.closeEntry();
@@ -97,7 +101,7 @@
 
       jarFile.deleteOnExit();
 
-      JarInputStream jarIn = new JarInputStream(new FileInputStream(jarFile));
+      JarInputStream jarIn = new JarInputStream(Tools.safeBufferedWrapper(new FileInputStream(jarFile)));
       Iterator i = Jar.iterator(jarIn);
       while (i.hasNext())
       {

Modified: trunk/core/src/main/org/jboss/portal/core/cms/servlet/CMSExportServlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/servlet/CMSExportServlet.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/core/src/main/org/jboss/portal/core/cms/servlet/CMSExportServlet.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -21,6 +21,8 @@
 */
 package org.jboss.portal.core.cms.servlet;
 
+import org.jboss.portal.common.util.Tools;
+
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -28,6 +30,8 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.BufferedInputStream;
 
 /**
  * Used for archive export in CMS.
@@ -51,7 +55,7 @@
          response.setContentLength((int) file.length());
          response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
 
-         FileInputStream in = new FileInputStream(file);
+         InputStream in = Tools.safeBufferedWrapper(new FileInputStream(file));
          ServletOutputStream sout = response.getOutputStream();
          byte[] buf = new byte[2048];
          int len;

Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -102,7 +102,7 @@
       {
          // Load xml document
          log.debug("Loading portal metadata from " + url);
-         in = url.openStream();
+         in = Tools.safeBufferedWrapper(url.openStream());
          DocumentBuilder builder = XML.getDocumentBuilderFactory().newDocumentBuilder();
          Document doc = builder.parse(in);
          Element deploymentsElt = doc.getDocumentElement();

Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -161,7 +161,7 @@
                      InputStream in = null;
                      try
                      {
-                        in = url.openStream();
+                        in = Tools.safeBufferedWrapper(url.openStream());
                         Document doc = builder.parse(in);
                         Element deploymentsElt = doc.getDocumentElement();
                         for (Iterator i = XML.getChildrenIterator(deploymentsElt, "deployment");i.hasNext();)
@@ -230,7 +230,7 @@
          InputStream in = null;
          try
          {
-            in = pwa.getServletContext().getResourceAsStream("/WEB-INF/portlet-instances.xml");
+            in = Tools.safeBufferedWrapper(pwa.getServletContext().getResourceAsStream("/WEB-INF/portlet-instances.xml"));
             if (in != null)
             {
                Document doc = builder.parse(in);

Modified: trunk/core/src/main/org/jboss/portal/test/core/Utils.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/Utils.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/core/src/main/org/jboss/portal/test/core/Utils.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -31,6 +31,7 @@
 import org.dbunit.database.IDatabaseConnection;
 import org.dbunit.dataset.IDataSet;
 import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.jboss.portal.common.util.Tools;
 
 /**
  * @author <a href="theute at jboss.org">Thomas Heute </a>
@@ -42,12 +43,12 @@
    private static String url = "jdbc:mysql://localhost:3306/jbossportal?useServerPrepStmts=false";
    private static String username = "portal";
    private static String password = "portalpassword";
-   
+
    public static IDataSet getDataSet(String file) throws Exception
    {
-       return new FlatXmlDataSet(new FileInputStream(file));
+       return new FlatXmlDataSet(Tools.safeBufferedWrapper(new FileInputStream(file)));
    }
-   
+
    public static IDatabaseConnection getConnection() throws Exception
    {
        Class driverClass = Class.forName("org.gjt.mm.mysql.Driver");

Modified: trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -60,6 +60,7 @@
 import javax.servlet.ServletContext;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.BufferedInputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -322,7 +323,7 @@
       InputStream sourceTLD = null;
       try
       {
-         sourceTLD = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jboss/portal/portlet/portlet.tld");
+         sourceTLD = Tools.safeBufferedWrapper(Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jboss/portal/portlet/portlet.tld"));
          pwa.importFile("/WEB-INF", "portlet.tld", sourceTLD, false);
       }
       catch (IOException e)
@@ -340,7 +341,7 @@
       InputStream in = null;
       try
       {
-         in = url.openStream();
+         in = Tools.safeBufferedWrapper(url.openStream());
          PortletApplicationMetaDataFactory factory = new PortletApplicationMetaDataFactory();
          Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
          PortletApplicationMetaData portletAppMD = (PortletApplicationMetaData)unmarshaller.unmarshal(in, new ValueTrimmingFilter(factory), null);
@@ -361,7 +362,7 @@
       InputStream in = null;
       try
       {
-         in = servletContext.getResourceAsStream("/WEB-INF/jboss-portlet.xml");
+         in = Tools.safeBufferedWrapper(servletContext.getResourceAsStream("/WEB-INF/jboss-portlet.xml"));
          if (in != null)
          {
             log.debug("Parsing jboss-portlet.xml" + contextPath);

Modified: trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -170,7 +170,7 @@
          InputStream in = null;
          try
          {
-            in = Thread.currentThread().getContextClassLoader().getResourceAsStream(standardJBossApplicationMetaDataLocation);
+            in = Tools.safeBufferedWrapper(Thread.currentThread().getContextClassLoader().getResourceAsStream(standardJBossApplicationMetaDataLocation));
             if (in != null)
             {
                JBossApplicationMetaDataFactory factory = createJBossApplicationMetaDataFactory();

Modified: trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/server/src/main/org/jboss/portal/server/deployment/PortalWebApp.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -34,6 +34,8 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.BufferedOutputStream;
+import java.io.OutputStream;
 import java.net.URL;
 
 /**
@@ -152,10 +154,10 @@
       File targetFile = new File(parentDir, name);
       if (overwrite || !targetFile.exists())
       {
-         FileOutputStream target = null;
+         OutputStream target = null;
          try
          {
-            target = new FileOutputStream(new File(parentDir, name));
+            target = Tools.safeBufferedWrapper(new FileOutputStream(new File(parentDir, name)));
             Tools.copy(source, target);
             done = true;
             log.debug("Copied file" + name + " to location " + parentDirRelativePath);
@@ -203,7 +205,7 @@
       InputStream in = null;
       try
       {
-         in = getServletContext().getResourceAsStream("/WEB-INF/jboss-app.xml");
+         in = Tools.safeBufferedWrapper(getServletContext().getResourceAsStream("/WEB-INF/jboss-app.xml"));
          if (in != null)
          {
             descriptor = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(in);

Modified: trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -260,7 +260,7 @@
          InputStream in = null;
          try
          {
-            in = url.openStream();
+            in = Tools.safeBufferedWrapper(url.openStream());
             Document doc = XML.getDocumentBuilderFactory().newDocumentBuilder().parse(in);
             for (Iterator i = XML.getChildrenIterator(doc.getDocumentElement(), "datasource");i.hasNext();)
             {

Modified: trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutDeployment.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutDeployment.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutDeployment.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -75,7 +75,7 @@
       InputStream in = null;
       try
       {
-         in = url.openStream();
+         in = Tools.safeBufferedWrapper(url.openStream());
          LayoutService layoutService = factory.getLayoutService();
          RuntimeContext ctx = new RuntimeContext(pwa.getId(), pwa.getServletContext(), pwa.getContextPath(), pwa.getClassLoader());
          Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
@@ -103,7 +103,7 @@
          InputStream source = null;
          try
          {
-            source = Thread.currentThread().getContextClassLoader().getResourceAsStream("conf/theme/portal-layout.tld");
+            source = Tools.safeBufferedWrapper(Thread.currentThread().getContextClassLoader().getResourceAsStream("conf/theme/portal-layout.tld"));
             pwa.importFile("/WEB-INF/theme", "portal-layout.tld", source, false);
          }
          catch (IOException e)

Modified: trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutFeaturesDeployment.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutFeaturesDeployment.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/LayoutFeaturesDeployment.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -99,7 +99,7 @@
             InputStream stream = null;
             try
             {
-               stream = url.openStream();
+               stream = Tools.safeBufferedWrapper(url.openStream());
                if (isRenderSet)
                {
                   List renderSets = (List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(stream, new RenderSetMetaDataFactory(), null);

Modified: trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/ThemeDeployment.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/ThemeDeployment.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/theme/src/main/org/jboss/portal/theme/deployment/jboss/ThemeDeployment.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -71,7 +71,7 @@
       InputStream themeStream = null;
       try
       {
-         themeStream = url.openStream();
+         themeStream = Tools.safeBufferedWrapper(url.openStream());
 
          RuntimeContext ctx = new RuntimeContext(pwa.getId(), pwa.getServletContext(), pwa.getContextPath(), pwa.getClassLoader());
          List portalThemes = (List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(themeStream, new PortalThemeMetaDataFactory(), null);

Modified: trunk/tools/lib/explode.jar
===================================================================
(Binary files differ)

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java	2006-09-25 16:31:45 UTC (rev 5249)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java	2006-09-25 21:27:23 UTC (rev 5250)
@@ -23,6 +23,7 @@
 package org.jboss.portal.wsrp.services;
 
 import org.jboss.logging.Logger;
+import org.jboss.portal.common.util.Tools;
 import org.xml.sax.InputSource;
 
 import javax.wsdl.Definition;
@@ -181,7 +182,7 @@
          log.trace("getBaseInputSource [wsdlUrl=" + wsdlURL + "]");
          try
          {
-            InputStream is = wsdlURL.openStream();
+            InputStream is = Tools.safeBufferedWrapper(wsdlURL.openStream());
             if (is == null)
             {
                throw new IllegalArgumentException("Cannot obtain wsdl from [" + wsdlURL + "]");
@@ -255,7 +256,7 @@
          try
          {
             log.trace("Resolved to: " + wsdlImport);
-            InputStream is = new URL(wsdlImport).openStream();
+            InputStream is = Tools.safeBufferedWrapper(new URL(wsdlImport).openStream());
             if (is == null)
             {
                throw new IllegalArgumentException("Cannot import wsdl from [" + wsdlImport + "]");




More information about the jboss-svn-commits mailing list