EMBJOPR SVN: r1025 - in trunk/core/src/main: webapp/WEB-INF and 1 other directory.
by embjopr-commits@lists.jboss.org
Author: ips
Date: 2011-07-29 13:09:55 -0400 (Fri, 29 Jul 2011)
New Revision: 1025
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java
trunk/core/src/main/webapp/WEB-INF/components.xml
Log:
[EMBJOPR-259] fix so uploaded EAR and WAR files are not stored in byte arrays to prevent potentially consuming a lot of the app server's heap (https://issues.jboss.org/browse/EMBJOPR-359)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java 2011-07-28 21:24:15 UTC (rev 1024)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java 2011-07-29 17:09:55 UTC (rev 1025)
@@ -1,6 +1,6 @@
/*
* Embedded Jopr Project
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.InputStream;
import java.io.IOException;
import javax.faces.application.FacesMessage;
@@ -31,6 +32,8 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.faces.FacesMessages;
+import org.rhq.core.util.stream.StreamUtil;
+
import org.jboss.on.embedded.ui.BootstrapAction;
import org.jboss.on.embedded.ui.NavigationAction;
@@ -47,7 +50,7 @@
private final Log log = LogFactory.getLog(this.getClass());
private String fileName;
- private byte[] file;
+ private InputStream file;
private String fileContentType;
/**
@@ -72,14 +75,13 @@
{
uploadsDir.mkdirs();
- String baseName = new File(this.fileName).getName();
+ String baseName = new File(this.fileName).getName();
tempFile = new File(uploadsDir, baseName);
log.debug("Writing uploaded file to '" + tempFile + "'...");
FileOutputStream fos = new FileOutputStream(tempFile);
- fos.write(this.file);
- log.debug("Wrote " + this.file.length + " bytes to '" + tempFile + "'.");
- fos.close();
+ StreamUtil.copy(this.file, fos, true);
+ log.debug("Wrote " + tempFile.length() + " bytes to '" + tempFile + "'.");
}
catch (IOException e)
{
@@ -101,12 +103,12 @@
this.fileName = fileName;
}
- public byte[] getFile()
+ public InputStream getFile()
{
return file;
}
- public void setFile(byte[] file)
+ public void setFile(InputStream file)
{
this.file = file;
}
@@ -121,3 +123,4 @@
this.fileContentType = fileContentType;
}
}
+
Modified: trunk/core/src/main/webapp/WEB-INF/components.xml
===================================================================
--- trunk/core/src/main/webapp/WEB-INF/components.xml 2011-07-28 21:24:15 UTC (rev 1024)
+++ trunk/core/src/main/webapp/WEB-INF/components.xml 2011-07-29 17:09:55 UTC (rev 1025)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Embedded Jopr Project
- ~ Copyright (C) 2006-2009 Red Hat, Inc.
+ ~ Copyright (C) 2006-2011 Red Hat, Inc.
~ All rights reserved.
~
~ This program is free software; you can redistribute it and/or modify
@@ -21,8 +21,9 @@
<components xmlns="http://jboss.com/products/seam/components"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://jboss.com/products/seam/security"
+ xmlns:web="http://jboss.com/products/seam/web"
xsi:schemaLocation=
- "http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
+ "http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd">
<component name="org.jboss.seam.core.init">
@@ -39,6 +40,10 @@
<property name="scanPeriod">60000</property>
</component>
+ <!-- write uploaded WAR or EAR files out to temp files rather than storing
+ them in memory, to avoid consuming a lot of the app server's heap -->
+ <web:multipart-filter create-temp-files="true"/>
+
<!-- security stuff -->
<security:identity authenticate-method="#{authenticator.authenticate}"
jaas-config-name="jmx-console"/>
@@ -53,3 +58,4 @@
</event>
</components>
+
13 years, 5 months
EMBJOPR SVN: r1024 - in branches/AdminConsole_EAP_5_1/core/src/main: webapp/WEB-INF and 1 other directory.
by embjopr-commits@lists.jboss.org
Author: ips
Date: 2011-07-28 17:24:15 -0400 (Thu, 28 Jul 2011)
New Revision: 1024
Modified:
branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java
branches/AdminConsole_EAP_5_1/core/src/main/webapp/WEB-INF/components.xml
Log:
[EMBJOPR-259] prevent large uploade ears or wars from taking up lots of heap as follows: 1) have Seam inject the uploaded ear or war file into the component as an InputStream rather than as a byte[], and 2) configure the Seam upload filter to store the uploaded file in a temp file rather than in memory (https://issues.jboss.org/browse/EMBJOPR-359)
Modified: branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java
===================================================================
--- branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java 2011-05-19 21:09:38 UTC (rev 1023)
+++ branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/content/AbstractFileUploadAction.java 2011-07-28 21:24:15 UTC (rev 1024)
@@ -1,6 +1,6 @@
/*
* Embedded Jopr Project
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.InputStream;
import java.io.IOException;
import javax.faces.application.FacesMessage;
@@ -31,6 +32,8 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.faces.FacesMessages;
+import org.rhq.core.util.stream.StreamUtil;
+
import org.jboss.on.embedded.ui.BootstrapAction;
import org.jboss.on.embedded.ui.NavigationAction;
@@ -47,7 +50,7 @@
private final Log log = LogFactory.getLog(this.getClass());
private String fileName;
- private byte[] file;
+ private InputStream file;
private String fileContentType;
/**
@@ -72,14 +75,16 @@
{
uploadsDir.mkdirs();
- String baseName = new File(this.fileName).getName();
+ String baseName = new File(this.fileName).getName();
tempFile = new File(uploadsDir, baseName);
log.debug("Writing uploaded file to '" + tempFile + "'...");
+
FileOutputStream fos = new FileOutputStream(tempFile);
- fos.write(this.file);
- log.debug("Wrote " + this.file.length + " bytes to '" + tempFile + "'.");
- fos.close();
+
+ StreamUtil.copy(this.file, fos, true);
+
+ log.debug("Wrote " + tempFile.length() + " bytes to '" + tempFile + "'.");
}
catch (IOException e)
{
@@ -101,12 +106,12 @@
this.fileName = fileName;
}
- public byte[] getFile()
+ public InputStream getFile()
{
return file;
}
- public void setFile(byte[] file)
+ public void setFile(InputStream file)
{
this.file = file;
}
Modified: branches/AdminConsole_EAP_5_1/core/src/main/webapp/WEB-INF/components.xml
===================================================================
--- branches/AdminConsole_EAP_5_1/core/src/main/webapp/WEB-INF/components.xml 2011-05-19 21:09:38 UTC (rev 1023)
+++ branches/AdminConsole_EAP_5_1/core/src/main/webapp/WEB-INF/components.xml 2011-07-28 21:24:15 UTC (rev 1024)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Embedded Jopr Project
- ~ Copyright (C) 2006-2009 Red Hat, Inc.
+ ~ Copyright (C) 2006-2011 Red Hat, Inc.
~ All rights reserved.
~
~ This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
<components xmlns="http://jboss.com/products/seam/components"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://jboss.com/products/seam/security"
+ xmlns:web="http://jboss.com/products/seam/web"
xsi:schemaLocation=
"http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd">
@@ -39,6 +40,10 @@
<property name="scanPeriod">60000</property>
</component>
+ <!-- write uploaded WAR or EAR files out to temp files rather than storing
+ them in memory, to avoid consuming a lot of the app server's heap -->
+ <web:multipart-filter create-temp-files="true"/>
+
<!-- security stuff -->
<security:identity authenticate-method="#{authenticator.authenticate}"
jaas-config-name="jmx-console"/>
@@ -53,3 +58,4 @@
</event>
</components>
+
13 years, 5 months