JBossWeb SVN: r2105 - branches/7.2.x/webapps/docs.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2012-10-08 09:48:50 -0400 (Mon, 08 Oct 2012)
New Revision: 2105
Modified:
branches/7.2.x/webapps/docs/build.xml
branches/7.2.x/webapps/docs/rewrite.xml
Log:
Arrange the rewrite docs and the build.xml to generate it.
Modified: branches/7.2.x/webapps/docs/build.xml
===================================================================
--- branches/7.2.x/webapps/docs/build.xml 2012-10-08 10:01:35 UTC (rev 2104)
+++ branches/7.2.x/webapps/docs/build.xml 2012-10-08 13:48:50 UTC (rev 2105)
@@ -57,11 +57,6 @@
<copy tofile="${webapps.build}/${webapp.name}/appdev/sample/build.xml"
file="appdev/build.xml.txt"/>
- <!-- Architecture -->
- <copy todir="${webapps.build}/${webapp.name}/architecture">
- <fileset dir="architecture" excludes="*.xml"/>
- </copy>
-
<!-- Images Subdirectory -->
<mkdir dir="${webapps.build}/${webapp.name}/images"/>
<copy todir="${webapps.build}/${webapp.name}/images">
@@ -173,26 +168,6 @@
<param name="project-menu" expression="nomenu"/>
</style>
- <!-- Server Architecture -->
- <style basedir="architecture"
- destdir="${webapps.build}/${webapp.name}/architecture"
- extension=".html"
- style="tomcat-docs.xsl"
- excludes="project.xml"
- includes="*.xml">
- <param name="relative-path" expression=".."/>
- </style>
- <mkdir dir="${webapps.build}/${webapp.name}/architecture/printer"/>
- <style basedir="architecture"
- destdir="${webapps.build}/${webapp.name}/architecture/printer"
- extension=".html"
- style="tomcat-docs.xsl"
- excludes="project.xml"
- includes="*.xml">
- <param name="relative-path" expression="../.."/>
- <param name="project-menu" expression="nomenu"/>
- </style>
-
</target>
Modified: branches/7.2.x/webapps/docs/rewrite.xml
===================================================================
--- branches/7.2.x/webapps/docs/rewrite.xml 2012-10-08 10:01:35 UTC (rev 2104)
+++ branches/7.2.x/webapps/docs/rewrite.xml 2012-10-08 13:48:50 UTC (rev 2105)
@@ -8,7 +8,8 @@
<properties>
<author email="mladen.turk(a)jboss.com">Mladen Turk</author>
- <title>Overview</title>
+ <author email="jfclere(a)gmail.com">Jean-Frederic Clere</author>
+ <title>The rewrite Valve</title>
</properties>
<body>
@@ -22,24 +23,20 @@
<section name="Configuration">
- <p>The rewrite valve is configured as a regular valve, by adding the following
- to server.xml as child of an Engine or Host element (or inside a context.xml
- file):</p>
-
- <source><Valve className="org.jboss.web.rewrite.RewriteValve" /></source>
+ <p>The rewrite valve can be configured as a valve added in a virtual-host.
+ See <a href="config/host.html">virtual-server</a> documentation for
+ informations how to configure it.
+ </p>
+ <p>It can also be in the jboss-web.xml of a webapp configured as a normal value:
+ </p>
+ <source>
+<valve>
+ <class-name>org.jboss.web.rewrite.RewriteValve"</class-name>
+</valve>
+ </source>
<p>The valve will then use a <code>rewrite.properties</code> file containing the
- rewrite directives, located according to the container it is assocaited to:
- <ul>
- <li>If associated with an engine, it should be placed in a folder named
- [engine_name] placed either in the classloader, or in the conf folder of the current
- JBoss profile</li>
- <li>If associated with a host, it should be placed in a folder named
- [engine_name]/[host_name] placed either in the classloader, or in the conf folder of the current
- JBoss profile</li>
- <li>If associated with a context, it should be placed in the WEB-INF folder of the web
- application</li>
- </ul>
+ rewrite directives, it must be placed in the WEB-INF folder of the web application
</p>
</section>
12 years, 2 months
JBossWeb SVN: r2104 - sandbox/webapps/src.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2012-10-08 06:01:35 -0400 (Mon, 08 Oct 2012)
New Revision: 2104
Modified:
sandbox/webapps/src/TestSnoop.java
Log:
Add a bunch of request elements (for ssl tests).
Modified: sandbox/webapps/src/TestSnoop.java
===================================================================
--- sandbox/webapps/src/TestSnoop.java 2012-10-04 14:28:30 UTC (rev 2103)
+++ sandbox/webapps/src/TestSnoop.java 2012-10-08 10:01:35 UTC (rev 2104)
@@ -71,8 +71,22 @@
out.println(new Date(session.getLastAccessedTime()));
System.out.println("Created: " + new Date(session.getLastAccessedTime()));
+ System.out.println("Content length: " + request.getContentLength());
+ System.out.println("getParameterNames: " + request.getParameterNames());
+
out.println("Paramters:<br>");
Enumeration e = request.getParameterNames();
+ System.out.println("getParameterNames: " + e.hasMoreElements());
+ if (request.getContentLength() == 1030) {
+ ServletInputStream in = request.getInputStream();
+ for (;;) {
+ byte[] buff = new byte[128];
+ if (in.readLine(buff,0,128)==-1) {
+ out.println("<br>End of posted data");
+ break;
+ }
+ }
+ }
for ( ; e.hasMoreElements() ;) {
String name = (String) e.nextElement();
String value = request.getParameter(name);
@@ -86,7 +100,12 @@
e = request.getAttributeNames();
for ( ; e.hasMoreElements() ;) {
String name = (String) e.nextElement();
- String value = (String) request.getAttribute(name);
+ String value = "";
+ try {
+ value = (String) request.getAttribute(name);
+ } catch (Exception ex) {
+ ex.printStackTrace(out);
+ }
out.println("<P>");
out.println("name: " + name + " value: " + value);
out.println("<P>");
@@ -102,6 +121,8 @@
out.println("<br>LocalPort: " + request.getLocalPort());
out.println("<br>LocalAddr: " + request.getLocalAddr());
out.println("<br>LocalName: " + request.getLocalName());
+ out.println("<br>Secure: " + request.isSecure());
+ out.println("<br>Secure: " + request.getScheme());
}
12 years, 2 months
JBossWeb SVN: r2103 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-04 10:28:30 -0400 (Thu, 04 Oct 2012)
New Revision: 2103
Added:
tags/JBOSSWEB_7_2_0_ALPHA2/
Log:
Web 7.2.0 Alpha2.
12 years, 2 months
JBossWeb SVN: r2102 - branches/7.2.x/src/main/java/org/apache/tomcat/util/net.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-04 10:27:42 -0400 (Thu, 04 Oct 2012)
New Revision: 2102
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
Log:
- Cleanup maxThreads and maxConnections, since they will be set properly in AS.
- Use the same defaults as for the APR connector.
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java 2012-10-04 13:21:08 UTC (rev 2101)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java 2012-10-04 14:27:42 UTC (rev 2102)
@@ -89,13 +89,12 @@
/**
* Maximum amount of worker threads.
*/
- protected int maxThreads = (org.apache.tomcat.util.Constants.LOW_MEMORY) ? 32 : 32 * Runtime
- .getRuntime().availableProcessors();
+ protected int maxThreads = (org.apache.tomcat.util.Constants.LOW_MEMORY) ? 32 : ((Constants.MAX_THREADS == -1) ? 32 * Runtime.getRuntime().availableProcessors() : Constants.MAX_THREADS);
/**
* The maximum number of connections
*/
- protected int maxConnections = 1024;
+ protected int maxConnections = (org.apache.tomcat.util.Constants.LOW_MEMORY) ? 1024 : (32 * 1024);
/**
* Priority of the acceptor and poller threads.
@@ -105,7 +104,7 @@
/**
* Size of the sendfile (= concurrent files which can be served).
*/
- protected int sendfileSize = -1;
+ protected int sendfileSize = (org.apache.tomcat.util.Constants.LOW_MEMORY) ? 128 : (16 * 1024);
/**
* Server socket port.
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2012-10-04 13:21:08 UTC (rev 2101)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2012-10-04 14:27:42 UTC (rev 2102)
@@ -242,7 +242,7 @@
running = true;
paused = false;
- // Start acceptor threads
+ // Start acceptor threads
for (int i = 0; i < acceptorThreadCount; i++) {
Thread acceptorThread = newThread(new Acceptor(), "Acceptor", daemon);
acceptorThread.start();
@@ -257,7 +257,7 @@
}
// Starting the event poller
- this.eventPoller = new EventPoller(this.maxThreads);
+ this.eventPoller = new EventPoller(this.maxConnections);
this.eventPoller.init();
Thread eventPollerThread = newThread(this.eventPoller, "EventPoller", true);
eventPollerThread.start();
@@ -1639,7 +1639,7 @@
* Initialize the {@code Sendfile}
*/
protected void init() {
- this.size = maxThreads;
+ this.size = sendfileSize;
this.mutex = new Object();
this.counter = new AtomicInteger(0);
this.fileDatas = new ConcurrentLinkedQueue<SendfileData>();
12 years, 2 months
JBossWeb SVN: r2101 - in branches/7.2.x: src/main/java/org/apache/tomcat/util/net and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-04 09:21:08 -0400 (Thu, 04 Oct 2012)
New Revision: 2101
Modified:
branches/7.2.x/pom.xml
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java
Log:
Adjust default for reuseAddress, with a system property (not trying to avoid setting it yet).
Modified: branches/7.2.x/pom.xml
===================================================================
(Binary files differ)
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java 2012-10-03 11:15:25 UTC (rev 2100)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java 2012-10-04 13:21:08 UTC (rev 2101)
@@ -60,7 +60,7 @@
/**
*
*/
- protected boolean reuseAddress = false;
+ protected boolean reuseAddress = Constants.REUSE_ADDRESS;
/**
* Current worker threads busy count.
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java 2012-10-03 11:15:25 UTC (rev 2100)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java 2012-10-04 13:21:08 UTC (rev 2101)
@@ -30,6 +30,9 @@
public static final boolean WAIT_FOR_THREAD =
Boolean.valueOf(System.getProperty("org.apache.tomcat.util.net.WAIT_FOR_THREAD", "false")).booleanValue();
+ public static final boolean REUSE_ADDRESS =
+ Boolean.valueOf(System.getProperty("org.apache.tomcat.util.net.REUSE_ADDRESS", "true")).booleanValue();
+
/**
* The Request attribute key for the cipher suite.
*/
12 years, 2 months
JBossWeb SVN: r2100 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-03 07:15:25 -0400 (Wed, 03 Oct 2012)
New Revision: 2100
Added:
tags/JBOSSWEB_7_2_0_ALPHA1/
Log:
First 7.2 build for testing
12 years, 2 months
JBossWeb SVN: r2099 - branches/7.2.x.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-03 06:58:09 -0400 (Wed, 03 Oct 2012)
New Revision: 2099
Modified:
branches/7.2.x/pom.xml
Log:
Change version number
Modified: branches/7.2.x/pom.xml
===================================================================
(Binary files differ)
12 years, 2 months
JBossWeb SVN: r2098 - in branches/7.2.x/src/main/java/org: apache/tomcat/util/http/fileupload and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-03 04:12:39 -0400 (Wed, 03 Oct 2012)
New Revision: 2098
Added:
branches/7.2.x/src/main/java/org/jboss/web/FileUploadMessages.java
Modified:
branches/7.2.x/src/main/java/org/apache/jasper/tagplugins/jstl/Util.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileCleaningTracker.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileDeleteStrategy.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUtils.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
branches/7.2.x/src/main/java/org/jboss/web/JasperMessages.java
Log:
Visual inspection of util (part 3) classes for i18n
Modified: branches/7.2.x/src/main/java/org/apache/jasper/tagplugins/jstl/Util.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/jasper/tagplugins/jstl/Util.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/jasper/tagplugins/jstl/Util.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -18,6 +18,8 @@
package org.apache.jasper.tagplugins.jstl;
+import static org.jboss.web.JasperMessages.MESSAGES;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
@@ -234,8 +236,7 @@
return url;
} else {
if (!context.startsWith("/") || !url.startsWith("/")) {
- throw new JspTagException(
- "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
+ throw new JspTagException(MESSAGES.invalidContextAndUrlValues());
}
if (context.equals("/")) {
// Don't produce string starting with '//', many
@@ -272,16 +273,14 @@
public PrintWriter getWriter() {
if (isStreamUsed)
- throw new IllegalStateException("Unexpected internal error during <import>: " +
- "Target servlet called getWriter(), then getOutputStream()");
+ throw MESSAGES.usedOutputStreamAfterWriter();
isWriterUsed = true;
return new PrintWriter(sw);
}
public ServletOutputStream getOutputStream() {
if (isWriterUsed)
- throw new IllegalStateException("Unexpected internal error during <import>: " +
- "Target servlet called getOutputStream(), then getWriter()");
+ throw MESSAGES.usedWriterAfterOutputStream();
isStreamUsed = true;
return sos;
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -81,8 +83,7 @@
*/
public ByteArrayOutputStream(int size) {
if (size < 0) {
- throw new IllegalArgumentException(
- "Negative initial size: " + size);
+ throw MESSAGES.negativeBufferSize(size);
}
needNewBuffer(size);
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -122,7 +124,7 @@
{
this(threshold, (File)null);
if (prefix == null) {
- throw new IllegalArgumentException("Temporary file prefix is missing");
+ throw MESSAGES.missingTemporaryFilePrefix();
}
this.prefix = prefix;
this.suffix = suffix;
@@ -250,7 +252,7 @@
// a file or memory.
if (!closed)
{
- throw new IOException("Stream not closed");
+ throw new IOException(MESSAGES.streamNotClosed());
}
if(isInMemory())
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileCleaningTracker.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileCleaningTracker.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileCleaningTracker.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.File;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
@@ -84,7 +86,7 @@
*/
public void track(File file, Object marker, FileDeleteStrategy deleteStrategy) {
if (file == null) {
- throw new NullPointerException("The file must not be null");
+ throw MESSAGES.nullFile();
}
addTracker(file.getPath(), marker, deleteStrategy);
}
@@ -114,7 +116,7 @@
*/
public void track(String path, Object marker, FileDeleteStrategy deleteStrategy) {
if (path == null) {
- throw new NullPointerException("The path must not be null");
+ throw MESSAGES.nullPath();
}
addTracker(path, marker, deleteStrategy);
}
@@ -129,7 +131,7 @@
private synchronized void addTracker(String path, Object marker, FileDeleteStrategy deleteStrategy) {
// synchronized block protects reaper
if (exitWhenFinished) {
- throw new IllegalStateException("No new trackers can be added once exitWhenFinished() is called");
+ throw MESSAGES.cannotAddTrackersOnceFinished();
}
if (reaper == null) {
reaper = new Reaper();
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileDeleteStrategy.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileDeleteStrategy.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileDeleteStrategy.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.File;
import java.io.IOException;
@@ -92,7 +94,7 @@
*/
public void delete(File fileToDelete) throws IOException {
if (fileToDelete.exists() && doDelete(fileToDelete) == false) {
- throw new IOException("Deletion failed: " + fileToDelete);
+ throw new IOException(MESSAGES.failedToDelete(fileToDelete.getAbsolutePath()));
}
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
@@ -26,8 +28,6 @@
import java.util.Map;
import java.util.NoSuchElementException;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.tomcat.util.http.fileupload.MultipartStream.ItemInputStream;
import org.apache.tomcat.util.http.fileupload.util.Closeable;
import org.apache.tomcat.util.http.fileupload.util.FileItemHeadersImpl;
@@ -304,8 +304,7 @@
FileItemIterator iter = getItemIterator(ctx);
FileItemFactory fac = getFileItemFactory();
if (fac == null) {
- throw new NullPointerException(
- "No FileItemFactory has been set.");
+ throw MESSAGES.nullFactory();
}
while (iter.hasNext()) {
final FileItemStream item = iter.next();
@@ -321,9 +320,8 @@
} catch (FileUploadIOException e) {
throw (FileUploadException) e.getCause();
} catch (IOException e) {
- throw new IOFileUploadException(
- "Processing of " + MULTIPART_FORM_DATA
- + " request failed. " + e.getMessage(), e);
+ throw new IOFileUploadException(MESSAGES.multipartProcessingFailed
+ (MULTIPART_FORM_DATA, e.getMessage()), e);
}
if (fileItem instanceof FileItemHeadersSupport) {
final FileItemHeaders fih = item.getHeaders();
@@ -528,8 +526,7 @@
for (;;) {
int offset = headerPart.indexOf('\r', index);
if (offset == -1 || offset + 1 >= headerPart.length()) {
- throw new IllegalStateException(
- "Expected headers to be terminated by an empty line.");
+ throw MESSAGES.emptyLineAfterHeaders();
}
if (headerPart.charAt(offset + 1) == '\n') {
return offset;
@@ -608,12 +605,8 @@
if (pContentLength != -1
&& pContentLength > fileSizeMax) {
FileSizeLimitExceededException e =
- new FileSizeLimitExceededException(
- "The field " + fieldName
- + " exceeds its maximum permitted "
- + " size of " + fileSizeMax
- + " bytes.",
- pContentLength, fileSizeMax);
+ new FileSizeLimitExceededException(MESSAGES.maxFieldSizeExceeded(fieldName, fileSizeMax),
+ pContentLength, fileSizeMax);
e.setFileName(pName);
e.setFieldName(pFieldName);
throw new FileUploadIOException(e);
@@ -624,11 +617,7 @@
throws IOException {
itemStream.close(true);
FileSizeLimitExceededException e =
- new FileSizeLimitExceededException(
- "The field " + fieldName
- + " exceeds its maximum permitted "
- + " size of " + pSizeMax
- + " bytes.",
+ new FileSizeLimitExceededException(MESSAGES.maxFieldSizeExceeded(fieldName, pSizeMax),
pCount, pSizeMax);
e.setFieldName(fieldName);
e.setFileName(name);
@@ -684,8 +673,7 @@
*/
public InputStream openStream() throws IOException {
if (opened) {
- throw new IllegalStateException(
- "The stream was already opened.");
+ throw MESSAGES.streamAlreadyOpened();
}
if (((Closeable) stream).isClosed()) {
throw new FileItemStream.ItemSkippedException();
@@ -762,19 +750,14 @@
FileItemIteratorImpl(RequestContext ctx)
throws FileUploadException, IOException {
if (ctx == null) {
- throw new NullPointerException("ctx parameter");
+ throw MESSAGES.nullContext();
}
String contentType = ctx.getContentType();
if ((null == contentType)
|| (!contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART))) {
- throw new InvalidContentTypeException(
- "the request doesn't contain a "
- + MULTIPART_FORM_DATA
- + " or "
- + MULTIPART_MIXED
- + " stream, content type header is "
- + contentType);
+ throw new InvalidContentTypeException(MESSAGES.invalidContentType
+ (MULTIPART_FORM_DATA, MULTIPART_MIXED, contentType));
}
InputStream input = ctx.getInputStream();
@@ -787,22 +770,14 @@
protected void raiseError(long pSizeMax, long pCount)
throws IOException {
FileUploadException ex =
- new SizeLimitExceededException(
- "the request was rejected because"
- + " its size (" + pCount
- + ") exceeds the configured maximum"
- + " (" + pSizeMax + ")",
+ new SizeLimitExceededException(MESSAGES.maxRequestSizeExceeded(pCount, pSizeMax),
pCount, pSizeMax);
throw new FileUploadIOException(ex);
}
};
} else {
if (sizeMax >= 0 && requestSize > sizeMax) {
- throw new SizeLimitExceededException(
- "the request was rejected because its size ("
- + requestSize
- + ") exceeds the configured maximum ("
- + sizeMax + ")",
+ throw new SizeLimitExceededException(MESSAGES.maxRequestSizeExceeded(requestSize, sizeMax),
requestSize, sizeMax);
}
}
@@ -815,9 +790,7 @@
boundary = getBoundary(contentType);
if (boundary == null) {
- throw new FileUploadException(
- "the request was rejected because "
- + "no multipart boundary was found");
+ throw new FileUploadException(MESSAGES.missingMultipartBoundary());
}
notifier = new MultipartStream.ProgressNotifier(listener,
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUtils.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUtils.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/FileUtils.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -79,9 +81,7 @@
cleanDirectory(directory);
if (!directory.delete()) {
- String message =
- "Unable to delete directory " + directory + ".";
- throw new IOException(message);
+ throw new IOException(MESSAGES.failedToDeleteDirectory(directory.getPath()));
}
}
@@ -95,18 +95,16 @@
*/
public static void cleanDirectory(File directory) throws IOException {
if (!directory.exists()) {
- String message = directory + " does not exist";
- throw new IllegalArgumentException(message);
+ throw MESSAGES.missingDirectory(directory.getPath());
}
if (!directory.isDirectory()) {
- String message = directory + " is not a directory";
- throw new IllegalArgumentException(message);
+ throw MESSAGES.notDirectory(directory.getPath());
}
File[] files = directory.listFiles();
if (files == null) { // null if security restricted
- throw new IOException("Failed to list contents of " + directory);
+ throw new IOException(MESSAGES.failedListingDirectory(directory.getPath()));
}
IOException exception = null;
@@ -148,11 +146,9 @@
boolean filePresent = file.exists();
if (!file.delete()) {
if (!filePresent){
- throw new FileNotFoundException("File does not exist: " + file);
+ throw new FileNotFoundException(MESSAGES.missingFile(file.getPath()));
}
- String message =
- "Unable to delete file: " + file;
- throw new IOException(message);
+ throw new IOException(MESSAGES.failedToDelete(file.getPath()));
}
}
}
@@ -198,18 +194,16 @@
*/
private static void cleanDirectoryOnExit(File directory) throws IOException {
if (!directory.exists()) {
- String message = directory + " does not exist";
- throw new IllegalArgumentException(message);
+ throw MESSAGES.missingDirectory(directory.getPath());
}
if (!directory.isDirectory()) {
- String message = directory + " is not a directory";
- throw new IllegalArgumentException(message);
+ throw MESSAGES.notDirectory(directory.getPath());
}
File[] files = directory.listFiles();
if (files == null) { // null if security restricted
- throw new IOException("Failed to list contents of " + directory);
+ throw new IOException(MESSAGES.failedListingDirectory(directory.getPath()));
}
IOException exception = null;
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -375,7 +377,7 @@
tail = input.read(buffer, head, bufSize);
if (tail == -1) {
// No more data available.
- throw new IOException("No more data is available");
+ throw new IOException(MESSAGES.noDataAvailable());
}
if (notifier != null) {
notifier.noteBytesRead(tail);
@@ -419,11 +421,10 @@
} else if (arrayequals(marker, FIELD_SEPARATOR, 2)) {
nextChunk = true;
} else {
- throw new MalformedStreamException(
- "Unexpected characters follow a boundary");
+ throw new MalformedStreamException(MESSAGES.unexpectedCharactersAfterBoundary());
}
} catch (IOException e) {
- throw new MalformedStreamException("Stream ended unexpectedly");
+ throw new MalformedStreamException(MESSAGES.unexpectedEndOfStream());
}
return nextChunk;
}
@@ -451,8 +452,7 @@
public void setBoundary(byte[] boundary)
throws IllegalBoundaryException {
if (boundary.length != boundaryLength - BOUNDARY_PREFIX.length) {
- throw new IllegalBoundaryException(
- "The length of a boundary token can not be changed");
+ throw new IllegalBoundaryException(MESSAGES.invalidBoundaryToken());
}
System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length,
boundary.length);
@@ -485,12 +485,10 @@
try {
b = readByte();
} catch (IOException e) {
- throw new MalformedStreamException("Stream ended unexpectedly");
+ throw new MalformedStreamException(MESSAGES.unexpectedEndOfStream());
}
if (++size > HEADER_PART_SIZE_MAX) {
- throw new MalformedStreamException(
- "Header section has more than " + HEADER_PART_SIZE_MAX
- + " bytes (maybe it is not properly terminated)");
+ throw new MalformedStreamException(MESSAGES.invalidHeader(HEADER_PART_SIZE_MAX));
}
if (b == HEADER_SEPARATOR[i]) {
i++;
@@ -939,8 +937,7 @@
// The last pad amount is left in the buffer.
// Boundary can't be in there so signal an error
// condition.
- final String msg = "Stream ended unexpectedly";
- throw new MalformedStreamException(msg);
+ throw new MalformedStreamException(MESSAGES.unexpectedEndOfStream());
}
if (notifier != null) {
notifier.noteBytesRead(bytesRead);
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload.disk;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -472,8 +474,7 @@
* For whatever reason we cannot write the
* file to disk.
*/
- throw new FileUploadException(
- "Cannot write uploaded file to disk!");
+ throw new FileUploadException(MESSAGES.errorWritingUpload());
}
}
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/util/Streams.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/fileupload/util/Streams.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.http.fileupload.util;
+import static org.jboss.web.FileUploadMessages.MESSAGES;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -191,7 +193,7 @@
}
}
throw new InvalidFileNameException(pFileName,
- "Invalid file name: " + sb);
+ MESSAGES.invalidFileName(sb.toString()));
}
return pFileName;
}
Added: branches/7.2.x/src/main/java/org/jboss/web/FileUploadMessages.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/FileUploadMessages.java (rev 0)
+++ branches/7.2.x/src/main/java/org/jboss/web/FileUploadMessages.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012 Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.web;
+
+import org.jboss.logging.Cause;
+import org.jboss.logging.Message;
+import org.jboss.logging.MessageBundle;
+import org.jboss.logging.Messages;
+
+/**
+ * Logging IDs 8200-8500
+ * @author Remy Maucherat
+ */
+@MessageBundle(projectCode = "JBWEB")
+public interface FileUploadMessages {
+
+ /**
+ * The messages
+ */
+ FileUploadMessages MESSAGES = Messages.getBundle(FileUploadMessages.class);
+
+ @Message(id = 8200, value = "Negative initial size: %s")
+ IllegalArgumentException negativeBufferSize(int size);
+
+ @Message(id = 8201, value = "Temporary file prefix is missing")
+ IllegalArgumentException missingTemporaryFilePrefix();
+
+ @Message(id = 8202, value = "Stream not closed")
+ String streamNotClosed();
+
+ @Message(id = 8203, value = "Null file")
+ NullPointerException nullFile();
+
+ @Message(id = 8204, value = "Null path")
+ NullPointerException nullPath();
+
+ @Message(id = 8205, value = "No new trackers can be added once finished")
+ IllegalStateException cannotAddTrackersOnceFinished();
+
+ @Message(id = 8206, value = "Deletion failed: %s")
+ String failedToDelete(String file);
+
+ @Message(id = 8207, value = "No FileItemFactory has been set")
+ NullPointerException nullFactory();
+
+ @Message(id = 8208, value = "Processing of %s request failed: %s")
+ String multipartProcessingFailed(String multipart, String message);
+
+ @Message(id = 8209, value = "Expected headers to be terminated by an empty line")
+ IllegalStateException emptyLineAfterHeaders();
+
+ @Message(id = 8210, value = "The field %s exceeds its maximum permitted size of %s bytes")
+ String maxFieldSizeExceeded(String field, long maxFileSize);
+
+ @Message(id = 8211, value = "The stream was already opened")
+ IllegalStateException streamAlreadyOpened();
+
+ @Message(id = 8212, value = "Null context")
+ NullPointerException nullContext();
+
+ @Message(id = 8213, value = "The request doesn't contain a %s or %s stream, content type header is %s")
+ String invalidContentType(String multipartForm, String multipartMixed, String contentType);
+
+ @Message(id = 8214, value = "The request was rejected because its size (%s) exceeds the configured maximum (%s)")
+ String maxRequestSizeExceeded(long requestSize, long maxRequestSize);
+
+ @Message(id = 8215, value = "The request was rejected because no multipart boundary was found")
+ String missingMultipartBoundary();
+
+ @Message(id = 8216, value = "Unable to delete directory %s")
+ String failedToDeleteDirectory(String directory);
+
+ @Message(id = 8217, value = "Directory %s does not exist")
+ IllegalArgumentException missingDirectory(String directory);
+
+ @Message(id = 8218, value = "Path %s is not a directory")
+ IllegalArgumentException notDirectory(String directory);
+
+ @Message(id = 8219, value = "Failed listing contents of directory %s")
+ String failedListingDirectory(String directory);
+
+ @Message(id = 8220, value = "File %s does not exist")
+ String missingFile(String file);
+
+ @Message(id = 8221, value = "Unable to delete file %s")
+ String failedToDeleteFile(String file);
+
+ @Message(id = 8222, value = "No more data is available")
+ String noDataAvailable();
+
+ @Message(id = 8223, value = "Unexpected characters follow a boundary")
+ String unexpectedCharactersAfterBoundary();
+
+ @Message(id = 8224, value = "Stream ended unexpectedly")
+ String unexpectedEndOfStream();
+
+ @Message(id = 8225, value = "The length of a boundary token can not be changed")
+ String invalidBoundaryToken();
+
+ @Message(id = 8226, value = "Header section has more than %s bytes (maybe it is not properly terminated)")
+ String invalidHeader(int maxHeaderSize);
+
+ @Message(id = 8227, value = "Cannot write uploaded file to disk")
+ String errorWritingUpload();
+
+ @Message(id = 8228, value = "Invalid file name: %s")
+ String invalidFileName(String fileName);
+
+}
Modified: branches/7.2.x/src/main/java/org/jboss/web/JasperMessages.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/JasperMessages.java 2012-10-03 08:11:09 UTC (rev 2097)
+++ branches/7.2.x/src/main/java/org/jboss/web/JasperMessages.java 2012-10-03 08:12:39 UTC (rev 2098)
@@ -772,4 +772,13 @@
@Message(id = 4244, value = "White space is required between the processing instruction target and data.")
String requiredWhiteSpaceAfterPiTarget();
+ @Message(id = 4245, value = "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with '/'.")
+ String invalidContextAndUrlValues();
+
+ @Message(id = 4246, value = "Unexpected internal error during <import>: Target servlet called getWriter(), then getOutputStream()")
+ IllegalStateException usedOutputStreamAfterWriter();
+
+ @Message(id = 4247, value = "Unexpected internal error during <import>: Target servlet called getOutputStream(), then getWriter()")
+ IllegalStateException usedWriterAfterOutputStream();
+
}
12 years, 2 months
JBossWeb SVN: r2097 - branches/7.2.x/src/main/java/org/apache/catalina/filters.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-03 04:11:09 -0400 (Wed, 03 Oct 2012)
New Revision: 2097
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/filters/CsrfPreventionFilter.java
Log:
Port patch.
Modified: branches/7.2.x/src/main/java/org/apache/catalina/filters/CsrfPreventionFilter.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/filters/CsrfPreventionFilter.java 2012-10-02 16:10:35 UTC (rev 2096)
+++ branches/7.2.x/src/main/java/org/apache/catalina/filters/CsrfPreventionFilter.java 2012-10-03 08:11:09 UTC (rev 2097)
@@ -35,6 +35,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
+import javax.servlet.http.HttpSession;
/**
* Provides basic CSRF protection for a web application. The filter assumes
@@ -141,16 +142,19 @@
}
}
+ HttpSession session = req.getSession(false);
+
@SuppressWarnings("unchecked")
- LruCache<String> nonceCache =
- (LruCache<String>) req.getSession(true).getAttribute(
+ LruCache<String> nonceCache = (session == null) ? null :
+ (LruCache<String>) session.getAttribute(
Constants.CSRF_NONCE_SESSION_ATTR_NAME);
if (!skipNonceCheck) {
String previousNonce =
req.getParameter(Constants.CSRF_NONCE_REQUEST_PARAM);
- if (nonceCache != null && !nonceCache.contains(previousNonce)) {
+ if (nonceCache == null || previousNonce == null
+ || !nonceCache.contains(previousNonce)) {
res.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -158,7 +162,10 @@
if (nonceCache == null) {
nonceCache = new LruCache<String>(nonceCacheSize);
- req.getSession().setAttribute(
+ if (session == null) {
+ session = req.getSession(true);
+ }
+ session.setAttribute(
Constants.CSRF_NONCE_SESSION_ATTR_NAME, nonceCache);
}
12 years, 2 months
JBossWeb SVN: r2096 - branches/7.0.x/java/org/apache/catalina/core.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-10-02 12:10:35 -0400 (Tue, 02 Oct 2012)
New Revision: 2096
Modified:
branches/7.0.x/java/org/apache/catalina/core/StandardHostValve.java
Log:
Port default error page (now clarified). Also port a minor additional patch.
Modified: branches/7.0.x/java/org/apache/catalina/core/StandardHostValve.java
===================================================================
--- branches/7.0.x/java/org/apache/catalina/core/StandardHostValve.java 2012-10-02 16:08:29 UTC (rev 2095)
+++ branches/7.0.x/java/org/apache/catalina/core/StandardHostValve.java 2012-10-02 16:10:35 UTC (rev 2096)
@@ -434,6 +434,10 @@
return;
ErrorPage errorPage = context.findErrorPage(statusCode);
+ if (errorPage == null) {
+ // Look for a default error page
+ errorPage = context.findErrorPage(0);
+ }
if (errorPage != null) {
response.setAppCommitted(false);
request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
@@ -524,6 +528,7 @@
// Reset the response (keeping the real error code and message)
response.resetBuffer(true);
+ response.setContentLength(-1);
// Forward control to the specified location
ServletContext servletContext =
12 years, 2 months