Author: remy.maucherat(a)jboss.com
Date: 2012-09-28 10:33:29 -0400 (Fri, 28 Sep 2012)
New Revision: 2091
Removed:
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardThreadExecutor.java
branches/7.2.x/src/main/java/org/apache/catalina/ha/
branches/7.2.x/src/main/java/org/apache/catalina/util/URL.java
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/BasicAuthenticator.java
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
branches/7.2.x/src/main/java/org/apache/catalina/connector/ConnectorMBean.java
branches/7.2.x/src/main/java/org/apache/catalina/connector/CoyoteReader.java
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardHostValve.java
branches/7.2.x/src/main/java/org/apache/catalina/filters/ExpiresFilter.java
branches/7.2.x/src/main/java/org/apache/catalina/filters/RemoteIpFilter.java
branches/7.2.x/src/main/java/org/apache/catalina/filters/WebdavFixFilter.java
branches/7.2.x/src/main/java/org/apache/catalina/realm/RealmBase.java
branches/7.2.x/src/main/java/org/apache/catalina/servlets/CGIServlet.java
branches/7.2.x/src/main/java/org/apache/catalina/servlets/DefaultServlet.java
branches/7.2.x/src/main/java/org/apache/catalina/session/StoreBase.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/ExpressionParseTree.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIConfig.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIEcho.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIExec.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFlastmod.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFsize.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIInclude.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIMediator.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIProcessor.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServlet.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSISet.java
branches/7.2.x/src/main/java/org/apache/catalina/util/ConcurrentMessageDigest.java
branches/7.2.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java
branches/7.2.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
branches/7.2.x/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
branches/7.2.x/src/main/java/org/jboss/web/CatalinaLogger.java
branches/7.2.x/src/main/java/org/jboss/web/CatalinaMessages.java
Log:
Visual inspection of the Catalina classes for i18n
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/BasicAuthenticator.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/BasicAuthenticator.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/BasicAuthenticator.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -31,7 +31,7 @@
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.CharChunk;
import org.apache.tomcat.util.buf.MessageBytes;
-import org.jboss.logging.Logger;
+import org.jboss.web.CatalinaLogger;
@@ -46,10 +46,8 @@
public class BasicAuthenticator
extends AuthenticatorBase {
- private static Logger log = Logger.getLogger(BasicAuthenticator.class);
-
/**
* Authenticate bytes.
*/
@@ -121,8 +119,8 @@
Principal principal = request.getUserPrincipal();
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (principal != null) {
- if (log.isDebugEnabled())
- log.debug("Already authenticated '" + principal.getName() +
"'");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Already authenticated '"
+ principal.getName() + "'");
// Associate the session with any existing SSO session
if (ssoId != null)
associate(ssoId, request.getSessionInternal(true));
@@ -131,8 +129,8 @@
// Is there an SSO session against which we can try to reauthenticate?
if (ssoId != null) {
- if (log.isDebugEnabled())
- log.debug("SSO Id " + ssoId + " set; attempting " +
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("SSO Id " + ssoId + "
set; attempting " +
"reauthentication");
/* Try to reauthenticate using data cached by SSO. If this fails,
either the original SSO logon was of DIGEST or SSL (which
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -42,7 +42,7 @@
import org.apache.tomcat.util.buf.CharChunk;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.MimeHeaders;
-import org.jboss.logging.Logger;
+import org.jboss.web.CatalinaLogger;
/**
@@ -57,8 +57,6 @@
public class FormAuthenticator
extends AuthenticatorBase {
- private static Logger log = Logger.getLogger(FormAuthenticator.class);
-
// ----------------------------------------------------- Instance Variables
@@ -156,8 +154,8 @@
Principal principal = request.getUserPrincipal();
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (principal != null) {
- if (log.isDebugEnabled())
- log.debug("Already authenticated '" +
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Already authenticated '"
+
principal.getName() + "'");
// Associate the session with any existing SSO session
if (ssoId != null)
@@ -167,8 +165,8 @@
// Is there an SSO session against which we can try to reauthenticate?
if (ssoId != null) {
- if (log.isDebugEnabled())
- log.debug("SSO Id " + ssoId + " set; attempting " +
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("SSO Id " + ssoId + "
set; attempting " +
"reauthentication");
// Try to reauthenticate using data cached by SSO. If this fails,
// either the original SSO logon was of DIGEST or SSL (which
@@ -183,15 +181,15 @@
// Have we authenticated this user before but have caching disabled?
if (!cache) {
session = request.getSessionInternal(true);
- if (log.isDebugEnabled())
- log.debug("Checking for reauthenticate in session " +
session);
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Checking for reauthenticate in
session " + session);
String username =
(String) session.getNote(Constants.SESS_USERNAME_NOTE);
String password =
(String) session.getNote(Constants.SESS_PASSWORD_NOTE);
if ((username != null) && (password != null)) {
- if (log.isDebugEnabled())
- log.debug("Reauthenticating username '" + username +
"'");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Reauthenticating username
'" + username + "'");
principal =
context.getRealm().authenticate(username, password);
if (principal != null) {
@@ -203,8 +201,8 @@
return (true);
}
}
- if (log.isDebugEnabled())
- log.debug("Reauthentication failed, proceed normally");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Reauthentication failed,
proceed normally");
}
}
@@ -212,8 +210,8 @@
// authentication? If so, forward the *original* request instead.
if (matchRequest(request)) {
session = request.getSessionInternal(true);
- if (log.isDebugEnabled())
- log.debug("Restore request from session '"
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Restore request from session
'"
+ session.getIdInternal()
+ "'");
principal = (Principal)
@@ -228,12 +226,12 @@
session.removeNote(Constants.SESS_PASSWORD_NOTE);
}
if (restoreRequest(request, session)) {
- if (log.isDebugEnabled())
- log.debug("Proceed to restored request");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Proceed to restored
request");
return (true);
} else {
- if (log.isDebugEnabled())
- log.debug("Restore of original request failed");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Restore of original request
failed");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return (false);
}
@@ -254,12 +252,12 @@
// No -- Save this request and redirect to the form login page
if (!loginAction) {
session = request.getSessionInternal(true);
- if (log.isDebugEnabled())
- log.debug("Save request in session '" +
session.getIdInternal() + "'");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Save request in session
'" + session.getIdInternal() + "'");
try {
saveRequest(request, session);
} catch (IOException ioe) {
- log.debug("Request body too big to save during
authentication");
+ CatalinaLogger.AUTH_LOGGER.debug("Request body too big to save
during authentication");
response.sendError(HttpServletResponse.SC_FORBIDDEN,
MESSAGES.requestBodyTooLarge());
return (false);
}
@@ -276,16 +274,16 @@
}
String username = request.getParameter(Constants.FORM_USERNAME);
String password = request.getParameter(Constants.FORM_PASSWORD);
- if (log.isDebugEnabled())
- log.debug("Authenticating username '" + username +
"'");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Authenticating username '" +
username + "'");
principal = realm.authenticate(username, password);
if (principal == null) {
forwardToErrorPage(request, response, config);
return (false);
}
- if (log.isDebugEnabled())
- log.debug("Authentication of '" + username + "' was
successful");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Authentication of '" +
username + "' was successful");
if (session == null)
session = request.getSessionInternal(false);
@@ -320,8 +318,8 @@
// Redirect the user to the original request URI (which will cause
// the original request to be restored)
requestURI = savedRequestURL(session);
- if (log.isDebugEnabled())
- log.debug("Redirecting to original '" + requestURI +
"'");
+ if (CatalinaLogger.AUTH_LOGGER.isDebugEnabled())
+ CatalinaLogger.AUTH_LOGGER.debug("Redirecting to original '" +
requestURI + "'");
if (requestURI == null)
if (landingPage == null) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST,
@@ -365,7 +363,7 @@
disp.forward(request.getRequest(), response);
} catch (Throwable t) {
String msg = MESSAGES.errorForwardingToFormLogin();
- log.warn(msg, t);
+ CatalinaLogger.AUTH_LOGGER.warn(msg, t);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
msg);
@@ -392,7 +390,7 @@
disp.forward(request.getRequest(), response);
} catch (Throwable t) {
String msg = MESSAGES.errorForwardingToFormError();
- log.warn(msg, t);
+ CatalinaLogger.AUTH_LOGGER.warn(msg, t);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
msg);
Modified: branches/7.2.x/src/main/java/org/apache/catalina/connector/ConnectorMBean.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/connector/ConnectorMBean.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/connector/ConnectorMBean.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.connector;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import javax.management.Attribute;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
@@ -81,8 +83,7 @@
// Validate the input parameters
if (name == null)
- throw new RuntimeOperationsException(new IllegalArgumentException(
- "Attribute name is null"), "Attribute name is
null");
+ throw new RuntimeOperationsException(MESSAGES.invalidNullAttributeName());
Object result = null;
try {
@@ -118,13 +119,11 @@
// Validate the input parameters
if (attribute == null)
- throw new RuntimeOperationsException(new IllegalArgumentException(
- "Attribute is null"), "Attribute is null");
+ throw new RuntimeOperationsException(MESSAGES.invalidNullAttribute());
String name = attribute.getName();
Object value = attribute.getValue();
if (name == null)
- throw new RuntimeOperationsException(new IllegalArgumentException(
- "Attribute name is null"), "Attribute name is
null");
+ throw new RuntimeOperationsException(MESSAGES.invalidNullAttributeName());
try {
Connector connector = (Connector) getManagedResource();
Modified: branches/7.2.x/src/main/java/org/apache/catalina/connector/CoyoteReader.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/connector/CoyoteReader.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/connector/CoyoteReader.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -18,6 +18,8 @@
package org.apache.catalina.connector;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.BufferedReader;
import java.io.IOException;
@@ -127,7 +129,7 @@
throws IOException {
// See BufferedReader#mark(int) JavaDoc
if (readAheadLimit < 0) {
- throw new IllegalArgumentException("readAheadLimit value is
negative");
+ throw MESSAGES.invalidReadAhead(readAheadLimit);
}
ib.mark(readAheadLimit);
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/core/StandardHostValve.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardHostValve.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardHostValve.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -370,8 +370,10 @@
if (custom(request, response, errorPage)) {
try {
response.flushBuffer();
+ } catch (ClientAbortException e) {
+ // Ignore
} catch (IOException e) {
- container.getLogger().warn("Exception Processing " +
errorPage, e);
+
container.getLogger().warn(MESSAGES.errorProcessingErrorPage(errorPage.getLocation()),
e);
}
}
} else {
@@ -445,7 +447,7 @@
} catch (ClientAbortException e) {
// Ignore
} catch (IOException e) {
- container.getLogger().warn("Exception Processing " +
errorPage, e);
+
container.getLogger().warn(MESSAGES.errorProcessingErrorPage(errorPage.getLocation()),
e);
}
}
}
@@ -524,7 +526,7 @@
} catch (Throwable t) {
// Report our failure to process this custom page
- container.getLogger().error("Exception Processing " + errorPage,
t);
+
container.getLogger().error(MESSAGES.errorProcessingErrorPage(errorPage.getLocation()),
t);
return (false);
}
Deleted:
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardThreadExecutor.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardThreadExecutor.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/core/StandardThreadExecutor.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.catalina.core;
-
-import java.util.Collection;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.catalina.Executor;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.util.LifecycleSupport;
-import java.util.concurrent.RejectedExecutionException;
-
-public class StandardThreadExecutor implements Executor {
-
- // ---------------------------------------------- Properties
- protected int threadPriority = Thread.NORM_PRIORITY;
-
- protected boolean daemon = true;
-
- protected String namePrefix = "tomcat-exec-";
-
- protected int maxThreads = 200;
-
- protected int minSpareThreads = 25;
-
- protected int maxIdleTime = 60000;
-
- protected ThreadPoolExecutor executor = null;
-
- protected String name;
-
- private LifecycleSupport lifecycle = new LifecycleSupport(this);
- // ---------------------------------------------- Constructors
- public StandardThreadExecutor() {
- //empty constructor for the digester
- }
-
-
-
- // ---------------------------------------------- Public Methods
- public void start() throws LifecycleException {
- lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
- TaskQueue taskqueue = new TaskQueue();
- TaskThreadFactory tf = new TaskThreadFactory(namePrefix);
- lifecycle.fireLifecycleEvent(START_EVENT, null);
- executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(),
maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
- taskqueue.setParent( (ThreadPoolExecutor) executor);
- lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
- }
-
- public void stop() throws LifecycleException{
- lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
- lifecycle.fireLifecycleEvent(STOP_EVENT, null);
- if ( executor != null ) executor.shutdown();
- executor = null;
- lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
- }
-
- public void execute(Runnable command) {
- if ( executor != null ) {
- try {
- executor.execute(command);
- } catch (RejectedExecutionException rx) {
- //there could have been contention around the queue
- if ( !( (TaskQueue) executor.getQueue()).force(command) ) throw new
RejectedExecutionException();
- }
- } else throw new IllegalStateException("StandardThreadPool not
started.");
- }
-
- public int getThreadPriority() {
- return threadPriority;
- }
-
- public boolean isDaemon() {
-
- return daemon;
- }
-
- public String getNamePrefix() {
- return namePrefix;
- }
-
- public int getMaxIdleTime() {
- return maxIdleTime;
- }
-
- public int getMaxThreads() {
- return maxThreads;
- }
-
- public int getMinSpareThreads() {
- return minSpareThreads;
- }
-
- public String getName() {
- return name;
- }
-
- public void setThreadPriority(int threadPriority) {
- this.threadPriority = threadPriority;
- }
-
- public void setDaemon(boolean daemon) {
- this.daemon = daemon;
- }
-
- public void setNamePrefix(String namePrefix) {
- this.namePrefix = namePrefix;
- }
-
- public void setMaxIdleTime(int maxIdleTime) {
- this.maxIdleTime = maxIdleTime;
- if (executor != null) {
- executor.setKeepAliveTime(maxIdleTime, TimeUnit.MILLISECONDS);
- }
- }
-
- public void setMaxThreads(int maxThreads) {
- this.maxThreads = maxThreads;
- if (executor != null) {
- executor.setMaximumPoolSize(maxThreads);
- }
- }
-
- public void setMinSpareThreads(int minSpareThreads) {
- this.minSpareThreads = minSpareThreads;
- if (executor != null) {
- executor.setCorePoolSize(minSpareThreads);
- }
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Add a LifecycleEvent listener to this component.
- *
- * @param listener The listener to add
- */
- public void addLifecycleListener(LifecycleListener listener) {
- lifecycle.addLifecycleListener(listener);
- }
-
-
- /**
- * Get the lifecycle listeners associated with this lifecycle. If this
- * Lifecycle has no listeners registered, a zero-length array is returned.
- */
- public LifecycleListener[] findLifecycleListeners() {
- return lifecycle.findLifecycleListeners();
- }
-
-
- /**
- * Remove a LifecycleEvent listener from this component.
- *
- * @param listener The listener to remove
- */
- public void removeLifecycleListener(LifecycleListener listener) {
- lifecycle.removeLifecycleListener(listener);
- }
-
- // Statistics from the thread pool
- public int getActiveCount() {
- return (executor != null) ? executor.getActiveCount() : 0;
- }
-
- public long getCompletedTaskCount() {
- return (executor != null) ? executor.getCompletedTaskCount() : 0;
- }
-
- public int getCorePoolSize() {
- return (executor != null) ? executor.getCorePoolSize() : 0;
- }
-
- public int getLargestPoolSize() {
- return (executor != null) ? executor.getLargestPoolSize() : 0;
- }
-
- public int getPoolSize() {
- return (executor != null) ? executor.getPoolSize() : 0;
- }
-
- public int getQueueSize() {
- return (executor != null) ? executor.getQueue().size() : -1;
- }
-
- // ---------------------------------------------- TaskQueue Inner Class
- class TaskQueue extends LinkedBlockingQueue<Runnable> {
- ThreadPoolExecutor parent = null;
-
- public TaskQueue() {
- super();
- }
-
- public TaskQueue(int initialCapacity) {
- super(initialCapacity);
- }
-
- public TaskQueue(Collection<? extends Runnable> c) {
- super(c);
- }
-
- public void setParent(ThreadPoolExecutor tp) {
- parent = tp;
- }
-
- public boolean force(Runnable o) {
- if ( parent.isShutdown() ) throw new
RejectedExecutionException("Executor not running, can't force a command into the
queue");
- return super.offer(o); //forces the item onto the queue, to be used if the
task is rejected
- }
-
- public boolean offer(Runnable o) {
- //we can't do any checks
- if (parent==null) return super.offer(o);
- //we are maxed out on threads, simply queue the object
- if (parent.getPoolSize() == parent.getMaximumPoolSize()) return
super.offer(o);
- //we have idle threads, just add it to the queue
- //this is an approximation, so it could use some tuning
- if (parent.getActiveCount()<(parent.getPoolSize())) return
super.offer(o);
- //if we have less threads than maximum force creation of a new thread
- if (parent.getPoolSize()<parent.getMaximumPoolSize()) return false;
- //if we reached here, we need to add it to the queue
- return super.offer(o);
- }
- }
-
- // ---------------------------------------------- ThreadFactory Inner Class
- class TaskThreadFactory implements ThreadFactory {
- final ThreadGroup group;
- final AtomicInteger threadNumber = new AtomicInteger(1);
- final String namePrefix;
-
- TaskThreadFactory(String namePrefix) {
- SecurityManager s = System.getSecurityManager();
- group = (s != null) ? s.getThreadGroup() :
Thread.currentThread().getThreadGroup();
- this.namePrefix = namePrefix;
- }
-
- public Thread newThread(Runnable r) {
- Thread t = new Thread(group, r, namePrefix +
threadNumber.getAndIncrement());
- t.setDaemon(daemon);
- t.setPriority(getThreadPriority());
- return t;
- }
- }
-
-
-}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/filters/ExpiresFilter.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/filters/ExpiresFilter.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/filters/ExpiresFilter.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -1044,9 +1044,7 @@
try {
ints[i] = Integer.parseInt(intAsString);
} catch (NumberFormatException e) {
- throw new RuntimeException("Exception parsing number '" + i
+
- "' (zero based) of comma delimited list '" +
- commaDelimitedInts + "'");
+ throw MESSAGES.invalidNumberInList(i, commaDelimitedInts);
}
}
return ints;
Modified: branches/7.2.x/src/main/java/org/apache/catalina/filters/RemoteIpFilter.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/filters/RemoteIpFilter.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/filters/RemoteIpFilter.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -13,6 +13,8 @@
*/
package org.apache.catalina.filters;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -613,7 +615,7 @@
try {
patternsList.add(Pattern.compile(pattern));
} catch (PatternSyntaxException e) {
- throw new IllegalArgumentException("Illegal pattern syntax
'" + pattern + "'", e);
+ throw MESSAGES.remoteIpValvePatternError(pattern, e);
}
}
return patternsList.toArray(new Pattern[0]);
@@ -844,7 +846,7 @@
try {
setHttpServerPort(Integer.parseInt(filterConfig.getInitParameter(HTTP_SERVER_PORT_PARAMETER)));
} catch (NumberFormatException e) {
- throw new NumberFormatException("Illegal " +
HTTP_SERVER_PORT_PARAMETER + " : " + e.getMessage());
+ throw
MESSAGES.invalidHttpPortNumber(filterConfig.getInitParameter(HTTP_SERVER_PORT_PARAMETER));
}
}
@@ -852,7 +854,7 @@
try {
setHttpsServerPort(Integer.parseInt(filterConfig.getInitParameter(HTTPS_SERVER_PORT_PARAMETER)));
} catch (NumberFormatException e) {
- throw new NumberFormatException("Illegal " +
HTTPS_SERVER_PORT_PARAMETER + " : " + e.getMessage());
+ throw
MESSAGES.invalidHttpsPortNumber(filterConfig.getInitParameter(HTTPS_SERVER_PORT_PARAMETER));
}
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/filters/WebdavFixFilter.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/filters/WebdavFixFilter.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/filters/WebdavFixFilter.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.filters;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import javax.servlet.Filter;
@@ -60,9 +62,6 @@
public class WebdavFixFilter implements Filter {
- private static final String LOG_MESSAGE_PREAMBLE =
- "WebdavFixFilter: Detected client problem: ";
-
/* Start string for all versions */
private static final String UA_MINIDIR_START =
"Microsoft-WebDAV-MiniRedir";
@@ -106,12 +105,11 @@
} else if (ua.startsWith(UA_MINIDIR_5_2_3790)) {
// XP 64-bit SP2
if (!"".equals(httpRequest.getContextPath())) {
- log(request,
- "XP-x64-SP2 clients only work with the root context");
+ request.getServletContext().log(MESSAGES.webDavClientProblemXpRootOnly());
}
// Namespace issue maybe
// see
http://greenbytes.de/tech/webdav/webdav-redirector-list.html
- log(request, "XP-x64-SP2 is known not to work with WebDAV Servlet");
+ request.getServletContext().log(MESSAGES.webDavClientProblemXp());
chain.doFilter(request, response);
} else {
@@ -137,9 +135,4 @@
return location.toString();
}
- private void log(ServletRequest request, String msg) {
- StringBuilder builder = new StringBuilder(LOG_MESSAGE_PREAMBLE);
- builder.append(msg);
- request.getServletContext().log(builder.toString());
- }
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/realm/RealmBase.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/realm/RealmBase.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/realm/RealmBase.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -1417,7 +1417,7 @@
else if( name.equalsIgnoreCase(STRICT_AUTH_ONLY_MODE.name) )
mode = STRICT_AUTH_ONLY_MODE;
else
- throw new IllegalStateException("Unknown mode, must be one of:
strict, authOnly, strictAuthOnly");
+ throw MESSAGES.unknownAuthMode(name);
return mode;
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/servlets/CGIServlet.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/servlets/CGIServlet.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/servlets/CGIServlet.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -18,6 +18,8 @@
package org.apache.catalina.servlets;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -1646,7 +1648,7 @@
response.addHeader(header , value);
}
} else {
- log("runCGI: bad header line \"" + line +
"\"");
+ log(MESSAGES.cgiInvalidHeader(line));
}
}
@@ -1690,7 +1692,7 @@
}
catch (IOException e){
- log ("Caught exception " + e);
+ log(MESSAGES.cgiException(e.getMessage()));
throw e;
}
finally{
@@ -1699,7 +1701,7 @@
try {
cgiHeaderReader.close();
} catch (IOException ioe) {
- log ("Exception closing header reader " + ioe);
+ log(MESSAGES.cgiExceptionClosingHeaderReader(ioe.getMessage()));
}
}
// Close the output stream if used
@@ -1707,7 +1709,7 @@
try {
cgiOutput.close();
} catch (IOException ioe) {
- log ("Exception closing output stream " + ioe);
+ log(MESSAGES.cgiExceptionClosingOutputStream(ioe.getMessage()));
}
}
// Make sure the error stream reader has finished
@@ -1715,7 +1717,7 @@
try {
errReaderThread.join(stderrTimeout);
} catch (InterruptedException e) {
- log ("Interupted waiting for stderr reader thread");
+ log(MESSAGES.cgiInterrupted());
}
}
if (debug > 4) {
@@ -1740,7 +1742,7 @@
if (statusStart < 1 || line.length() < statusStart + 3) {
// Not a valid HTTP Status-Line
- log ("runCGI: invalid HTTP Status-Line:" + line);
+ log(MESSAGES.cgiInvalidStatusLine(line));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1751,7 +1753,7 @@
statusCode = Integer.parseInt(status);
} catch (NumberFormatException nfe) {
// Not a valid status code
- log ("runCGI: invalid status code:" + status);
+ log(MESSAGES.cgiInvalidStatusCode(status));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1769,7 +1771,7 @@
private int getSCFromCGIStatusHeader(String value) {
if (value.length() < 3) {
// Not a valid status value
- log ("runCGI: invalid status value:" + value);
+ log(MESSAGES.cgiInvalidStatusValue(value));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1780,7 +1782,7 @@
statusCode = Integer.parseInt(status);
} catch (NumberFormatException nfe) {
// Not a valid status code
- log ("runCGI: invalid status code:" + status);
+ log(MESSAGES.cgiInvalidStatusCode(status));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1792,16 +1794,16 @@
int lineCount = 0 ;
try {
while ((line = rdr.readLine()) != null) {
- log("runCGI (stderr):" + line) ;
+ log(MESSAGES.cgiErrorLogPrefix(line)) ;
lineCount++ ;
}
} catch (IOException e) {
- log("sendToLog error", e) ;
+ log(MESSAGES.cgiStderrErrror(), e) ;
} finally {
try {
rdr.close() ;
} catch (IOException ce) {
- log("sendToLog error", ce) ;
+ log(MESSAGES.cgiStderrErrror(), ce) ;
}
}
if ( lineCount > 0 && debug > 2) {
Modified: branches/7.2.x/src/main/java/org/apache/catalina/servlets/DefaultServlet.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/servlets/DefaultServlet.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/servlets/DefaultServlet.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -1180,7 +1180,7 @@
} catch (NamingException e) {
// Something went wrong
- throw new ServletException("Error accessing resource", e);
+ throw new ServletException(MESSAGES.resourceNotAvailable(cacheEntry.name),
e);
}
sb.append("</entries>");
@@ -1210,7 +1210,7 @@
osWriter.flush();
return (new ByteArrayInputStream(stream.toByteArray()));
} catch (TransformerException e) {
- throw new ServletException("XSL transformer error", e);
+ throw new ServletException(MESSAGES.xslTransformerError(), e);
}
}
@@ -1355,7 +1355,7 @@
} catch (NamingException e) {
// Something went wrong
- throw new ServletException("Error accessing resource", e);
+ throw new ServletException(MESSAGES.resourceNotAvailable(cacheEntry.name),
e);
}
// Render the page footer
Modified: branches/7.2.x/src/main/java/org/apache/catalina/session/StoreBase.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/session/StoreBase.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/session/StoreBase.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -209,11 +209,11 @@
}
remove(keys[i]);
} catch (Exception e) {
- manager.getContainer().getLogger().error("Session:
"+keys[i]+"; ", e);
+
manager.getContainer().getLogger().error(MESSAGES.errorProcessingSessionExpires(keys[i]),
e);
try {
remove(keys[i]);
} catch (IOException e2) {
- manager.getContainer().getLogger().error("Error removing
key", e2);
+
manager.getContainer().getLogger().error(MESSAGES.errorRemovingKey(keys[i]), e2);
}
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/ExpressionParseTree.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/ssi/ExpressionParseTree.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/ssi/ExpressionParseTree.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,9 +17,12 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.text.ParseException;
import java.util.LinkedList;
import java.util.List;
+
/**
* Represents a parsed expression.
*
@@ -187,13 +190,13 @@
// Finish off the rest of the opps
resolveGroup();
if (nodeStack.size() == 0) {
- throw new ParseException("No nodes created.", et.getIndex());
+ throw new ParseException(MESSAGES.ssiParseNoNodes(), et.getIndex());
}
if (nodeStack.size() > 1) {
- throw new ParseException("Extra nodes created.", et.getIndex());
+ throw new ParseException(MESSAGES.ssiParseExtraNodes(), et.getIndex());
}
if (oppStack.size() != 0) {
- throw new ParseException("Unused opp nodes exist.",
et.getIndex());
+ throw new ParseException(MESSAGES.ssiParseUnusedNodes(), et.getIndex());
}
root = (Node)nodeStack.get(0);
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIConfig.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIConfig.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIConfig.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,7 +17,10 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.PrintWriter;
+
/**
* Implements the Server-side #exec command
*
@@ -45,7 +48,7 @@
} else if (paramName.equalsIgnoreCase("timefmt")) {
ssiMediator.setConfigTimeFmt(substitutedValue);
} else {
- ssiMediator.log("#config--Invalid attribute: " + paramName);
+ ssiMediator.log(MESSAGES.ssiInvalidAttribute("config",
paramName));
//We need to fetch this value each time, since it may change
// during the
// loop
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIEcho.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIEcho.java 2012-09-27 14:22:46
UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIEcho.java 2012-09-28 14:33:29
UTC (rev 2091)
@@ -17,7 +17,10 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.PrintWriter;
+
/**
* Return the result associated with the supplied Server Variable.
*
@@ -49,11 +52,11 @@
if (isValidEncoding(paramValue)) {
encoding = paramValue;
} else {
- ssiMediator.log("#echo--Invalid encoding: " + paramValue);
+ ssiMediator.log(MESSAGES.ssiEchoInvlidEncoding(paramValue));
writer.write(errorMessage);
}
} else {
- ssiMediator.log("#echo--Invalid attribute: " + paramName);
+ ssiMediator.log(MESSAGES.ssiInvalidAttribute("echo",
paramName));
writer.write(errorMessage);
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIExec.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIExec.java 2012-09-27 14:22:46
UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIExec.java 2012-09-28 14:33:29
UTC (rev 2091)
@@ -17,11 +17,14 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import org.apache.catalina.util.IOTools;
+
/**
* Implements the Server-side #exec command
*
@@ -74,7 +77,7 @@
//apache doesn't output an error message if it can't find
// a program
}
- ssiMediator.log("Couldn't exec file: " + substitutedValue,
e);
+ ssiMediator.log(MESSAGES.ssiExecFailed(substitutedValue), e);
}
}
return lastModified;
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFlastmod.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFlastmod.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFlastmod.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,11 +17,14 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import org.apache.catalina.util.DateTool;
import org.apache.catalina.util.Strftime;
+
/**
* Implements the Server-side #flastmod command
*
@@ -54,14 +57,11 @@
String configTimeFmt = ssiMediator.getConfigTimeFmt();
writer.write(formatDate(date, configTimeFmt));
} else {
- ssiMediator.log("#flastmod--Invalid attribute: "
- + paramName);
+ ssiMediator.log(MESSAGES.ssiInvalidAttribute("flastmod",
paramName));
writer.write(configErrMsg);
}
} catch (IOException e) {
- ssiMediator.log(
- "#flastmod--Couldn't get last modified for file: "
- + substitutedValue, e);
+ ssiMediator.log(MESSAGES.ssiFlastmodFailed(substitutedValue), e);
writer.write(configErrMsg);
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFsize.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFsize.java 2012-09-27 14:22:46
UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIFsize.java 2012-09-28 14:33:29
UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
@@ -57,12 +59,11 @@
String configSizeFmt = ssiMediator.getConfigSizeFmt();
writer.write(formatSize(size, configSizeFmt));
} else {
- ssiMediator.log("#fsize--Invalid attribute: " +
paramName);
+ ssiMediator.log(MESSAGES.ssiInvalidAttribute("fsize",
paramName));
writer.write(configErrMsg);
}
} catch (IOException e) {
- ssiMediator.log("#fsize--Couldn't get size for file: "
- + substitutedValue, e);
+ ssiMediator.log(MESSAGES.ssiFsizeFailed(substitutedValue), e);
writer.write(configErrMsg);
}
}
@@ -72,7 +73,7 @@
public String repeat(char aChar, int numChars) {
if (numChars < 0) {
- throw new IllegalArgumentException("Num chars can't be
negative");
+ throw MESSAGES.invalidNumChars();
}
StringBuilder buf = new StringBuilder();
for (int i = 0; i < numChars; i++) {
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIInclude.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIInclude.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIInclude.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,8 +17,11 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.io.PrintWriter;
+
/**
* Implements the Server-side #include command
*
@@ -51,13 +54,11 @@
virtual);
writer.write(text);
} else {
- ssiMediator.log("#include--Invalid attribute: "
- + paramName);
+ ssiMediator.log(MESSAGES.ssiInvalidAttribute("include",
paramName));
writer.write(configErrMsg);
}
} catch (IOException e) {
- ssiMediator.log("#include--Couldn't include file: "
- + substitutedValue, e);
+ ssiMediator.log(MESSAGES.ssiIncludeFailed(substitutedValue), e);
writer.write(configErrMsg);
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIMediator.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIMediator.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIMediator.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
@@ -29,6 +31,7 @@
import org.apache.catalina.util.Strftime;
import org.apache.catalina.util.URLEncoder;
import org.apache.tomcat.util.http.HttpMessages;
+
/**
* Allows the different SSICommand implementations to share data/talk to each
* other
@@ -41,7 +44,7 @@
* @version $Revision: 1473 $, $Date: 2010-05-17 19:46:58 +0200 (Mon, 17 May 2010) $
*/
public class SSIMediator {
- protected final static String DEFAULT_CONFIG_ERR_MSG = "[an error occurred while
processing this directive]";
+ protected final static String DEFAULT_CONFIG_ERR_MSG = MESSAGES.ssiDirectiveError();
protected final static String DEFAULT_CONFIG_TIME_FMT = "%A, %d-%b-%Y %T
%Z";
protected final static String DEFAULT_CONFIG_SIZE_FMT = "abbrev";
protected static URLEncoder urlEncoder;
@@ -305,7 +308,7 @@
retVal = HttpMessages.filter(value);
} else {
//This shouldn't be possible
- throw new IllegalArgumentException("Unknown encoding: " +
encoding);
+ throw new IllegalArgumentException(MESSAGES.ssiUnknownEncoding(encoding));
}
return retVal;
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIProcessor.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIProcessor.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIProcessor.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader;
@@ -25,6 +27,7 @@
import java.util.Locale;
import java.util.StringTokenizer;
import org.apache.catalina.util.IOTools;
+
/**
* The entry point to SSI processing. This class does the actual parsing,
* delegating to the SSIMediator, SSICommand, and SSIExternalResolver as
@@ -143,12 +146,11 @@
commands.get(strCmd.toLowerCase(Locale.ENGLISH));
String errorMessage = null;
if (ssiCommand == null) {
- errorMessage = "Unknown command: " + strCmd;
+ errorMessage = MESSAGES.ssiUnknownCommand(strCmd);
} else if (paramValues == null) {
- errorMessage = "Error parsing directive
parameters.";
+ errorMessage = MESSAGES.ssiParsingErrorNoParameters(strCmd);
} else if (paramNames.length != paramValues.length) {
- errorMessage = "Parameter names count does not match
parameter values count on command: "
- + strCmd;
+ errorMessage =
MESSAGES.ssiParsingErrorBadParameterCount(strCmd);
} else {
// don't process the command if we are processing
// conditional
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServlet.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServlet.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServlet.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -157,13 +157,11 @@
if (path == null ||
path.toUpperCase(Locale.ENGLISH).startsWith("/WEB-INF")
|| path.toUpperCase(Locale.ENGLISH).startsWith("/META-INF")) {
res.sendError(HttpServletResponse.SC_NOT_FOUND, path);
- log("Can't serve file: " + path);
return;
}
URL resource = servletContext.getResource(path);
if (resource == null) {
res.sendError(HttpServletResponse.SC_NOT_FOUND, path);
- log("Can't find file: " + path);
return;
}
String resourceMimeType = servletContext.getMimeType(path);
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServletExternalResolver.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServletExternalResolver.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSIServletExternalResolver.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
@@ -368,14 +370,12 @@
String pathWithoutContext = SSIServletRequestUtil.getRelativePath(req);
String prefix = getPathWithoutFileName(pathWithoutContext);
if (prefix == null) {
- throw new IOException("Couldn't remove filename from path: "
- + pathWithoutContext);
+ throw new
IOException(MESSAGES.ssiFailedRemovingFilename(pathWithoutContext));
}
String fullPath = prefix + path;
String retVal = SSIServletRequestUtil.normalize(fullPath);
if (retVal == null) {
- throw new IOException("Normalization yielded null on path: "
- + fullPath);
+ throw new IOException(MESSAGES.ssiFailedNormalization(fullPath));
}
return retVal;
}
@@ -384,12 +384,10 @@
protected ServletContextAndPath getServletContextAndPathFromNonVirtualPath(
String nonVirtualPath) throws IOException {
if (nonVirtualPath.startsWith("/") ||
nonVirtualPath.startsWith("\\")) {
- throw new IOException("A non-virtual path can't be absolute: "
- + nonVirtualPath);
+ throw new IOException(MESSAGES.ssiInvalidNonVirtualPath(nonVirtualPath));
}
if (nonVirtualPath.indexOf("../") >= 0) {
- throw new IOException("A non-virtual path can't contain
'../' : "
- + nonVirtualPath);
+ throw new
IOException(MESSAGES.ssiInvalidNonVirtualPathWithTraversal(nonVirtualPath));
}
String path = getAbsolutePath(nonVirtualPath);
ServletContextAndPath csAndP = new ServletContextAndPath(
@@ -411,8 +409,7 @@
} else {
ServletContext normContext = context.getContext(normalized);
if (normContext == null) {
- throw new IOException("Couldn't get context for path:
"
- + normalized);
+ throw new IOException(MESSAGES.ssiCannotGetContext(normalized));
}
//If it's the root context, then there is no context element
// to remove,
@@ -422,9 +419,7 @@
String noContext = getPathWithoutContext(
normContext.getContextPath(), normalized);
if (noContext == null) {
- throw new IOException(
- "Couldn't remove context from path: "
- + normalized);
+ throw new
IOException(MESSAGES.ssiCannotRemoveContext(normalized));
}
return new ServletContextAndPath(normContext, noContext);
} else {
@@ -516,8 +511,7 @@
String path = csAndP.getPath();
RequestDispatcher rd = context.getRequestDispatcher(path);
if (rd == null) {
- throw new IOException(
- "Couldn't get request dispatcher for path: " +
path);
+ throw new IOException(MESSAGES.ssiCannotGetRequestDispatcher(path));
}
ByteArrayServletOutputStream basos =
new ByteArrayServletOutputStream();
@@ -542,12 +536,11 @@
//were included, but not sure how else to tell.
if (retVal.equals("") &&
!req.getMethod().equalsIgnoreCase(
org.apache.coyote.http11.Constants.HEAD)) {
- throw new IOException("Couldn't find file: " + path);
+ throw new IOException(MESSAGES.ssiCannotFindFile(path));
}
return retVal;
} catch (ServletException e) {
- throw new IOException("Couldn't include file: " + originalPath
- + " because of ServletException: " + e.getMessage());
+ throw new IOException(MESSAGES.ssiServletIncludeFailed(originalPath), e);
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSISet.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSISet.java 2012-09-27 14:22:46
UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/ssi/SSISet.java 2012-09-28 14:33:29
UTC (rev 2091)
@@ -17,6 +17,8 @@
package org.apache.catalina.ssi;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.io.PrintWriter;
/**
* Implements the Server-side #set command
@@ -49,12 +51,12 @@
substitutedValue);
lastModified = System.currentTimeMillis();
} else {
- ssiMediator.log("#set--no variable specified");
+ ssiMediator.log(MESSAGES.ssiSetFailed());
writer.write(errorMessage);
throw new SSIStopProcessingException();
}
} else {
- ssiMediator.log("#set--Invalid attribute: " + paramName);
+ ssiMediator.log(MESSAGES.ssiInvalidAttribute("set",
paramName));
writer.write(errorMessage);
throw new SSIStopProcessingException();
}
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/util/ConcurrentMessageDigest.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/util/ConcurrentMessageDigest.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/util/ConcurrentMessageDigest.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -16,6 +16,8 @@
*/
package org.apache.catalina.util;
+import static org.jboss.web.CatalinaMessages.MESSAGES;
+
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
@@ -57,7 +59,7 @@
Queue<MessageDigest> queue = queues.get(algorithm);
if (queue == null) {
- throw new IllegalStateException("Must call init() first");
+ throw MESSAGES.uninitializedMessageDigest();
}
MessageDigest md = queue.poll();
@@ -67,7 +69,7 @@
} catch (NoSuchAlgorithmException e) {
// Ignore. Impossible if init() has been successfully called
// first.
- throw new IllegalStateException("Must call init() first");
+ throw MESSAGES.uninitializedMessageDigest();
}
}
Deleted: branches/7.2.x/src/main/java/org/apache/catalina/util/URL.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/util/URL.java 2012-09-27 14:22:46 UTC
(rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/util/URL.java 2012-09-28 14:33:29 UTC
(rev 2091)
@@ -1,709 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.catalina.util;
-
-
-import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.util.Locale;
-
-
-/**
- * <p><strong>URL</strong> is designed to provide public APIs for
parsing
- * and synthesizing Uniform Resource Locators as similar as possible to the
- * APIs of <code>java.net.URL</code>, but without the ability to open a
- * stream or connection. One of the consequences of this is that you can
- * construct URLs for protocols for which a URLStreamHandler is not
- * available (such as an "https" URL when JSSE is not installed).</p>
- *
- * <p><strong>WARNING</strong> - This class assumes that the string
- * representation of a URL conforms to the <code>spec</code> argument
- * as described in RFC 2396 "Uniform Resource Identifiers: Generic Syntax":
- * <pre>
- *
<scheme>//<authority><path>?<query>#<fragment>
- * </pre></p>
- *
- * <p><strong>FIXME</strong> - This class really ought to end up in a
Commons
- * package someplace.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision: 1473 $ $Date: 2010-05-17 19:46:58 +0200 (Mon, 17 May 2010) $
- */
-
-public final class URL implements Serializable {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Create a URL object from the specified String representation.
- *
- * @param spec String representation of the URL
- *
- * @exception MalformedURLException if the string representation
- * cannot be parsed successfully
- */
- public URL(String spec) throws MalformedURLException {
-
- this(null, spec);
-
- }
-
-
- /**
- * Create a URL object by parsing a string representation relative
- * to a specified context. Based on logic from JDK 1.3.1's
- * <code>java.net.URL</code>.
- *
- * @param context URL against which the relative representation
- * is resolved
- * @param spec String representation of the URL (usually relative)
- *
- * @exception MalformedURLException if the string representation
- * cannot be parsed successfully
- */
- public URL(URL context, String spec) throws MalformedURLException {
-
- String original = spec;
- int i, limit, c;
- int start = 0;
- String newProtocol = null;
- boolean aRef = false;
-
- try {
-
- // Eliminate leading and trailing whitespace
- limit = spec.length();
- while ((limit > 0) && (spec.charAt(limit - 1) <= ' '))
{
- limit--;
- }
- while ((start < limit) && (spec.charAt(start) <= ' '))
{
- start++;
- }
-
- // If the string representation starts with "url:", skip it
- if (spec.regionMatches(true, start, "url:", 0, 4)) {
- start += 4;
- }
-
- // Is this a ref relative to the context URL?
- if ((start < spec.length()) && (spec.charAt(start) ==
'#')) {
- aRef = true;
- }
-
- // Parse out the new protocol
- for (i = start; !aRef && (i < limit) &&
- ((c = spec.charAt(i)) != '/'); i++) {
- if (c == ':') {
- String s = spec.substring(start, i).toLowerCase(Locale.ENGLISH);
- // Assume all protocols are valid
- newProtocol = s;
- start = i + 1;
- break;
- }
- }
-
- // Only use our context if the protocols match
- protocol = newProtocol;
- if ((context != null) && ((newProtocol == null) ||
- newProtocol.equalsIgnoreCase(context.getProtocol()))) {
- // If the context is a hierarchical URL scheme and the spec
- // contains a matching scheme then maintain backwards
- // compatibility and treat it as if the spec didn't contain
- // the scheme; see 5.2.3 of RFC2396
- if ((context.getPath() != null) &&
- (context.getPath().startsWith("/")))
- newProtocol = null;
- if (newProtocol == null) {
- protocol = context.getProtocol();
- authority = context.getAuthority();
- userInfo = context.getUserInfo();
- host = context.getHost();
- port = context.getPort();
- file = context.getFile();
- int question = file.lastIndexOf("?");
- if (question < 0)
- path = file;
- else
- path = file.substring(0, question);
- }
- }
-
- if (protocol == null)
- throw new MalformedURLException("no protocol: " + original);
-
- // Parse out any ref portion of the spec
- i = spec.indexOf('#', start);
- if (i >= 0) {
- ref = spec.substring(i + 1, limit);
- limit = i;
- }
-
- // Parse the remainder of the spec in a protocol-specific fashion
- parse(spec, start, limit);
- if (context != null)
- normalize();
-
-
- } catch (MalformedURLException e) {
- throw e;
- } catch (Exception e) {
- throw new MalformedURLException(e.toString());
- }
-
- }
-
-
-
-
-
- /**
- * Create a URL object from the specified components. The default port
- * number for the specified protocol will be used.
- *
- * @param protocol Name of the protocol to use
- * @param host Name of the host addressed by this protocol
- * @param file Filename on the specified host
- *
- * @exception MalformedURLException is never thrown, but present for
- * compatible APIs
- */
- public URL(String protocol, String host, String file)
- throws MalformedURLException {
-
- this(protocol, host, -1, file);
-
- }
-
-
- /**
- * Create a URL object from the specified components. Specifying a port
- * number of -1 indicates that the URL should use the default port for
- * that protocol. Based on logic from JDK 1.3.1's
- * <code>java.net.URL</code>.
- *
- * @param protocol Name of the protocol to use
- * @param host Name of the host addressed by this protocol
- * @param port Port number, or -1 for the default port for this protocol
- * @param file Filename on the specified host
- *
- * @exception MalformedURLException is never thrown, but present for
- * compatible APIs
- */
- public URL(String protocol, String host, int port, String file)
- throws MalformedURLException {
-
- this.protocol = protocol;
- this.host = host;
- this.port = port;
-
- int hash = file.indexOf('#');
- this.file = hash < 0 ? file : file.substring(0, hash);
- this.ref = hash < 0 ? null : file.substring(hash + 1);
- int question = file.lastIndexOf('?');
- if (question >= 0) {
- query = file.substring(question + 1);
- path = file.substring(0, question);
- } else
- path = file;
-
- if ((host != null) && (host.length() > 0))
- authority = (port == -1) ? host : host + ":" + port;
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The authority part of the URL.
- */
- private String authority = null;
-
-
- /**
- * The filename part of the URL.
- */
- private String file = null;
-
-
- /**
- * The host name part of the URL.
- */
- private String host = null;
-
-
- /**
- * The path part of the URL.
- */
- private String path = null;
-
-
- /**
- * The port number part of the URL.
- */
- private int port = -1;
-
-
- /**
- * The protocol name part of the URL.
- */
- private String protocol = null;
-
-
- /**
- * The query part of the URL.
- */
- private String query = null;
-
-
- /**
- * The reference part of the URL.
- */
- private String ref = null;
-
-
- /**
- * The user info part of the URL.
- */
- private String userInfo = null;
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Compare two URLs for equality. The result is <code>true</code> if
and
- * only if the argument is not null, and is a <code>URL</code> object
- * that represents the same <code>URL</code> as this object. Two
- * <code>URLs</code> are equal if they have the same protocol and
- * reference the same host, the same port number on the host,
- * and the same file and anchor on the host.
- *
- * @param obj The URL to compare against
- */
- public boolean equals(Object obj) {
-
- if (obj == null)
- return (false);
- if (!(obj instanceof URL))
- return (false);
- URL other = (URL) obj;
- if (!sameFile(other))
- return (false);
- return (compare(ref, other.getRef()));
-
- }
-
-
- /**
- * Return the authority part of the URL.
- */
- public String getAuthority() {
-
- return (this.authority);
-
- }
-
-
- /**
- * Return the filename part of the URL. <strong>NOTE</strong> - For
- * compatibility with <code>java.net.URL</code>, this value includes
- * the query string if there was one. For just the path portion,
- * call <code>getPath()</code> instead.
- */
- public String getFile() {
-
- if (file == null)
- return ("");
- return (this.file);
-
- }
-
-
- /**
- * Return the host name part of the URL.
- */
- public String getHost() {
-
- return (this.host);
-
- }
-
-
- /**
- * Return the path part of the URL.
- */
- public String getPath() {
-
- if (this.path == null)
- return ("");
- return (this.path);
-
- }
-
-
- /**
- * Return the port number part of the URL.
- */
- public int getPort() {
-
- return (this.port);
-
- }
-
-
- /**
- * Return the protocol name part of the URL.
- */
- public String getProtocol() {
-
- return (this.protocol);
-
- }
-
-
- /**
- * Return the query part of the URL.
- */
- public String getQuery() {
-
- return (this.query);
-
- }
-
-
- /**
- * Return the reference part of the URL.
- */
- public String getRef() {
-
- return (this.ref);
-
- }
-
-
- /**
- * Return the user info part of the URL.
- */
- public String getUserInfo() {
-
- return (this.userInfo);
-
- }
-
-
- /**
- * Normalize the <code>path</code> (and therefore
<code>file</code>)
- * portions of this URL.
- * <p>
- * <strong>NOTE</strong> - This method is not part of the public API
- * of <code>java.net.URL</code>, but is provided as a value added
- * service of this implementation.
- *
- * @exception MalformedURLException if a normalization error occurs,
- * such as trying to move about the hierarchical root
- */
- public void normalize() throws MalformedURLException {
-
- // Special case for null path
- if (path == null) {
- if (query != null)
- file = "?" + query;
- else
- file = "";
- return;
- }
-
- // Create a place for the normalized path
- String normalized = path;
- if (normalized.equals("/.")) {
- path = "/";
- if (query != null)
- file = path + "?" + query;
- else
- file = path;
- return;
- }
-
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- if (!normalized.startsWith("/"))
- normalized = "/" + normalized;
-
- // Resolve occurrences of "//" in the normalized path
- while (true) {
- int index = normalized.indexOf("//");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 1);
- }
-
- // Resolve occurrences of "/./" in the normalized path
- while (true) {
- int index = normalized.indexOf("/./");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 2);
- }
-
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- throw new MalformedURLException
- ("Invalid relative URL reference");
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Resolve occurrences of "/." at the end of the normalized path
- if (normalized.endsWith("/."))
- normalized = normalized.substring(0, normalized.length() - 1);
-
- // Resolve occurrences of "/.." at the end of the normalized path
- if (normalized.endsWith("/..")) {
- int index = normalized.length() - 3;
- int index2 = normalized.lastIndexOf('/', index - 1);
- if (index2 < 0)
- throw new MalformedURLException
- ("Invalid relative URL reference");
- normalized = normalized.substring(0, index2 + 1);
- }
-
- // Return the normalized path that we have completed
- path = normalized;
- if (query != null)
- file = path + "?" + query;
- else
- file = path;
-
- }
-
-
- /**
- * Compare two URLs, excluding the "ref" fields. Returns
<code>true</code>
- * if this <code>URL</code> and the <code>other</code>
argument both refer
- * to the same resource. The two <code>URLs</code> might not both
contain
- * the same anchor.
- */
- public boolean sameFile(URL other) {
-
- if (!compare(protocol, other.getProtocol()))
- return (false);
- if (!compare(host, other.getHost()))
- return (false);
- if (port != other.getPort())
- return (false);
- if (!compare(file, other.getFile()))
- return (false);
- return (true);
-
- }
-
-
- /**
- * Return a string representation of this URL. This follow the rules in
- * RFC 2396, Section 5.2, Step 7.
- */
- public String toExternalForm() {
-
- StringBuffer sb = new StringBuffer();
- if (protocol != null) {
- sb.append(protocol);
- sb.append(":");
- }
- if (authority != null) {
- sb.append("//");
- sb.append(authority);
- }
- if (path != null)
- sb.append(path);
- if (query != null) {
- sb.append('?');
- sb.append(query);
- }
- if (ref != null) {
- sb.append('#');
- sb.append(ref);
- }
- return (sb.toString());
-
- }
-
-
- /**
- * Return a string representation of this object.
- */
- public String toString() {
-
- StringBuffer sb = new StringBuffer("URL[");
- sb.append("authority=");
- sb.append(authority);
- sb.append(", file=");
- sb.append(file);
- sb.append(", host=");
- sb.append(host);
- sb.append(", port=");
- sb.append(port);
- sb.append(", protocol=");
- sb.append(protocol);
- sb.append(", query=");
- sb.append(query);
- sb.append(", ref=");
- sb.append(ref);
- sb.append(", userInfo=");
- sb.append(userInfo);
- sb.append("]");
- return (sb.toString());
-
- // return (toExternalForm());
-
- }
-
-
- // -------------------------------------------------------- Private Methods
-
-
- /**
- * Compare to String values for equality, taking appropriate care if one
- * or both of the values are <code>null</code>.
- *
- * @param first First string
- * @param second Second string
- */
- private boolean compare(String first, String second) {
-
- if (first == null) {
- if (second == null)
- return (true);
- else
- return (false);
- } else {
- if (second == null)
- return (false);
- else
- return (first.equals(second));
- }
-
- }
-
-
- /**
- * Parse the specified portion of the string representation of a URL,
- * assuming that it has a format similar to that for <code>http</code>.
- *
- * <p><strong>FIXME</strong> - This algorithm can undoubtedly be
optimized
- * for performance. However, that needs to wait until after sufficient
- * unit tests are implemented to guarantee correct behavior with no
- * regressions.</p>
- *
- * @param spec String representation being parsed
- * @param start Starting offset, which will be just after the ':' (if
- * there is one) that determined the protocol name
- * @param limit Ending position, which will be the position of the '#'
- * (if there is one) that delimited the anchor
- *
- * @exception MalformedURLException if a parsing error occurs
- */
- private void parse(String spec, int start, int limit)
- throws MalformedURLException {
-
- // Trim the query string (if any) off the tail end
- int question = spec.lastIndexOf('?', limit - 1);
- if ((question >= 0) && (question < limit)) {
- query = spec.substring(question + 1, limit);
- limit = question;
- } else {
- query = null;
- }
-
- // Parse the authority section
- if (spec.indexOf("//", start) == start) {
- int pathStart = spec.indexOf("/", start + 2);
- if ((pathStart >= 0) && (pathStart < limit)) {
- authority = spec.substring(start + 2, pathStart);
- start = pathStart;
- } else {
- authority = spec.substring(start + 2, limit);
- start = limit;
- }
- if (authority.length() > 0) {
- int at = authority.indexOf('@');
- if( at >= 0 ) {
- userInfo = authority.substring(0,at);
- }
- int colon = authority.indexOf(':',at+1);
- if (colon >= 0) {
- try {
- port =
- Integer.parseInt(authority.substring(colon + 1));
- } catch (NumberFormatException e) {
- throw new MalformedURLException(e.toString());
- }
- host = authority.substring(at+1, colon);
- } else {
- host = authority.substring(at+1);
- port = -1;
- }
- }
- }
-
- // Parse the path section
- if (spec.indexOf("/", start) == start) { // Absolute path
- path = spec.substring(start, limit);
- if (query != null)
- file = path + "?" + query;
- else
- file = path;
- return;
- }
-
- // Resolve relative path against our context's file
- if (path == null) {
- if (query != null)
- file = "?" + query;
- else
- file = null;
- return;
- }
- if (!path.startsWith("/"))
- throw new MalformedURLException
- ("Base path does not start with '/'");
- if (!path.endsWith("/"))
- path += "/../";
- path += spec.substring(start, limit);
- if (query != null)
- file = path + "?" + query;
- else
- file = path;
- return;
-
- }
-
-
-}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java 2012-09-27
14:22:46 UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -45,6 +45,7 @@
import org.apache.catalina.util.LifecycleSupport;
import org.apache.coyote.RequestInfo;
import org.jboss.logging.Logger;
+import org.jboss.web.CatalinaLogger;
/**
@@ -122,8 +123,6 @@
extends ValveBase
implements Lifecycle {
- private static Logger log = Logger.getLogger(AccessLogValve.class);
-
// ----------------------------------------------------- Instance Variables
@@ -597,7 +596,7 @@
try {
holder.renameTo(new File(newFileName));
} catch (Throwable e) {
- log.error("rotate failed", e);
+ CatalinaLogger.VALVES_LOGGER.errorRotatingAccessLog(e);
}
/* Make sure date is correct */
@@ -669,7 +668,7 @@
try {
close();
} catch (Throwable e) {
- log.info("at least this wasn't swallowed", e);
+ CatalinaLogger.VALVES_LOGGER.errorClosingOldAccessLog(e);
}
/* Make sure date is correct */
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -35,7 +35,7 @@
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.LifecycleSupport;
-import org.jboss.logging.Logger;
+import org.jboss.web.CatalinaLogger;
/**
* Web crawlers can trigger the creation of many thousands of sessions as they
@@ -47,8 +47,6 @@
public class CrawlerSessionManagerValve extends ValveBase
implements Lifecycle, HttpSessionBindingListener {
- private static Logger log = Logger.getLogger(CrawlerSessionManagerValve.class);
-
/**
* The lifecycle event support for this component.
*/
@@ -164,8 +162,8 @@
String sessionId = null;
String clientIp = null;
- if (log.isDebugEnabled()) {
- log.debug(request.hashCode() + ": ClientIp=" +
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug(request.hashCode() + ":
ClientIp=" +
request.getRemoteAddr() + ", RequestedSessionId=" +
request.getRequestedSessionId());
}
@@ -183,15 +181,15 @@
// If more than one UA header - assume not a bot
if (uaHeader != null && !uaHeaders.hasMoreElements()) {
- if (log.isDebugEnabled()) {
- log.debug(request.hashCode() + ": UserAgent=" + uaHeader);
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug(request.hashCode() + ":
UserAgent=" + uaHeader);
}
if (uaPattern.matcher(uaHeader).matches()) {
isBot = true;
- if (log.isDebugEnabled()) {
- log.debug(request.hashCode() +
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug(request.hashCode() +
": Bot found. UserAgent=" + uaHeader);
}
}
@@ -203,8 +201,8 @@
sessionId = clientIpSessionId.get(clientIp);
if (sessionId != null) {
request.setRequestedSessionId(sessionId);
- if (log.isDebugEnabled()) {
- log.debug(request.hashCode() + ": SessionID=" +
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug(request.hashCode() + ":
SessionID=" +
sessionId);
}
}
@@ -224,14 +222,14 @@
s.setAttribute(this.getClass().getName(), this);
s.setMaxInactiveInterval(sessionInactiveInterval);
- if (log.isDebugEnabled()) {
- log.debug(request.hashCode() +
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug(request.hashCode() +
": New bot session. SessionID=" + s.getId());
}
}
} else {
- if (log.isDebugEnabled()) {
- log.debug(request.hashCode() +
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug(request.hashCode() +
": Bot session accessed. SessionID=" + sessionId);
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java 2012-09-27
14:22:46 UTC (rev 2090)
+++
branches/7.2.x/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java 2012-09-28
14:33:29 UTC (rev 2091)
@@ -36,8 +36,7 @@
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.ServerInfo;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CatalinaLogger;
@@ -132,8 +131,6 @@
extends AccessLogValve
implements Lifecycle {
- private static Logger log = Logger.getLogger(ExtendedAccessLogValve.class);
-
// ----------------------------------------------------- Instance Variables
@@ -533,8 +530,8 @@
}
protected AccessLogElement[] createLogElements() {
- if (log.isDebugEnabled()) {
- log.debug("decodePattern, pattern =" + pattern);
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug("decodePattern, pattern =" +
pattern);
}
List<AccessLogElement> list = new ArrayList<AccessLogElement>();
@@ -545,14 +542,14 @@
tokenizer.getWhiteSpaces();
if (tokenizer.isEnded()) {
- log.info("pattern was just empty or whitespace");
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogEmptyPattern();
return null;
}
String token = tokenizer.getToken();
while (token != null) {
- if (log.isDebugEnabled()) {
- log.debug("token = " + token);
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug("token = " + token);
}
AccessLogElement element = getLogElement(token, tokenizer);
if (element == null) {
@@ -568,12 +565,12 @@
}
token = tokenizer.getToken();
}
- if (log.isDebugEnabled()) {
- log.debug("finished decoding with element size of: " +
list.size());
+ if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
+ CatalinaLogger.VALVES_LOGGER.debug("finished decoding with element
size of: " + list.size());
}
return (AccessLogElement[]) list.toArray(new AccessLogElement[0]);
} catch (IOException e) {
- log.error("parse error", e);
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogPatternParseError(e);
return null;
}
}
@@ -629,7 +626,7 @@
} else if ("x".equals(token)) {
return getXParameterElement(tokenizer);
}
- log.error("unable to decode with rest of chars starting: " + token);
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogUnknownToken(token);
return null;
}
@@ -677,13 +674,12 @@
} else if (tokenizer.hasParameter()) {
String parameter = tokenizer.getParameter();
if (parameter == null) {
- log.error("No closing ) found for in decode");
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogMissingClosing();
return null;
}
return new RequestHeaderElement(parameter);
}
- log.error("The next characters couldn't be decoded: "
- + tokenizer.getRemains());
+
CatalinaLogger.VALVES_LOGGER.extendedAccessLogCannotDecode(tokenizer.getRemains());
return null;
}
@@ -699,13 +695,12 @@
} else if (tokenizer.hasParameter()) {
String parameter = tokenizer.getParameter();
if (parameter == null) {
- log.error("No closing ) found for in decode");
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogMissingClosing();
return null;
}
return new ResponseHeaderElement(parameter);
}
- log.error("The next characters couldn't be decoded: "
- + tokenizer.getRemains());
+
CatalinaLogger.VALVES_LOGGER.extendedAccessLogCannotDecode(tokenizer.getRemains());
return null;
}
@@ -719,24 +714,24 @@
tokenizer.getParameter();
return new StringElement("-");
}
- log.error("The next characters couldn't be decoded: " + token);
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogCannotDecode(token);
return null;
}
protected AccessLogElement getXParameterElement(PatternTokenizer tokenizer)
throws IOException {
if (!tokenizer.hasSubToken()) {
- log.error("x param in wrong format. Needs to be 'x-#(...)' read
the docs!");
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogBadXParam();
return null;
}
String token = tokenizer.getToken();
if (!tokenizer.hasParameter()) {
- log.error("x param in wrong format. Needs to be 'x-#(...)' read
the docs!");
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogBadXParam();
return null;
}
String parameter = tokenizer.getParameter();
if (parameter == null) {
- log.error("No closing ) found for in decode");
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogMissingClosing();
return null;
}
if ("A".equals(token)) {
@@ -754,8 +749,7 @@
} else if ("O".equals(token)) {
return new ResponseAllHeaderElement(parameter);
}
- log.error("x param for servlet request, couldn't decode value: "
- + token);
+ CatalinaLogger.VALVES_LOGGER.extendedAccessLogCannotDecodeXParamValue(token);
return null;
}
@@ -839,8 +833,7 @@
}
};
}
- log.error("x param for servlet request, couldn't decode value: "
- + parameter);
+
CatalinaLogger.VALVES_LOGGER.extendedAccessLogCannotDecodeXParamValue(parameter);
return null;
}
Modified: branches/7.2.x/src/main/java/org/jboss/web/CatalinaLogger.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/CatalinaLogger.java 2012-09-27 14:22:46 UTC
(rev 2090)
+++ branches/7.2.x/src/main/java/org/jboss/web/CatalinaLogger.java 2012-09-28 14:33:29 UTC
(rev 2091)
@@ -653,4 +653,40 @@
@Message(id = 1141, value = "NIO 2 is not available, the java.io connector will
be used insteaf")
void usingJavaIoConnector();
+ @LogMessage(level = ERROR)
+ @Message(id = 1142, value = "Access log rotation failed")
+ void errorRotatingAccessLog(@Cause Throwable t);
+
+ @LogMessage(level = INFO)
+ @Message(id = 1143, value = "Error closing old log file")
+ void errorClosingOldAccessLog(@Cause Throwable t);
+
+ @LogMessage(level = INFO)
+ @Message(id = 1144, value = "Pattern was just empty or whitespace")
+ void extendedAccessLogEmptyPattern();
+
+ @LogMessage(level = ERROR)
+ @Message(id = 1145, value = "Pattern parse error")
+ void extendedAccessLogPatternParseError(@Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 1146, value = "Unable to decode with rest of chars starting:
%s")
+ void extendedAccessLogUnknownToken(String token);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 1147, value = "No closing ) found for in decode")
+ void extendedAccessLogMissingClosing();
+
+ @LogMessage(level = ERROR)
+ @Message(id = 1148, value = "The next characters couldn't be decoded:
%s")
+ void extendedAccessLogCannotDecode(String chars);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 1149, value = "X param for servlet request, couldn't decode
value: %s")
+ void extendedAccessLogCannotDecodeXParamValue(String value);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 1150, value = "X param in wrong format. Needs to be
'x-#(...)'")
+ void extendedAccessLogBadXParam();
+
}
Modified: branches/7.2.x/src/main/java/org/jboss/web/CatalinaMessages.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/CatalinaMessages.java 2012-09-27 14:22:46
UTC (rev 2090)
+++ branches/7.2.x/src/main/java/org/jboss/web/CatalinaMessages.java 2012-09-28 14:33:29
UTC (rev 2091)
@@ -822,4 +822,151 @@
@Message(id = 309, value = "type")
String statusType();
+ @Message(id = 310, value = "Null attribute name")
+ IllegalArgumentException invalidNullAttributeName();
+
+ @Message(id = 311, value = "Null attribute")
+ IllegalArgumentException invalidNullAttribute();
+
+ @Message(id = 312, value = "Invalid negative read ahead %s specified")
+ IllegalArgumentException invalidReadAhead(int readAhead);
+
+ @Message(id = 313, value = "Exception processing error page %s")
+ String errorProcessingErrorPage(String location);
+
+ @Message(id = 314, value = "Exception parsing number %s (zero based) of comma
delimited list %s")
+ IllegalArgumentException invalidNumberInList(int number, String list);
+
+ @Message(id = 315, value = "Invalid HTTP port number specified %s")
+ IllegalArgumentException invalidHttpPortNumber(String port);
+
+ @Message(id = 316, value = "Invalid HTTPS port number specified %s")
+ IllegalArgumentException invalidHttpsPortNumber(String port);
+
+ @Message(id = 317, value = "WebDAV client problem: XP-x64-SP2 clients only work
with the root context")
+ String webDavClientProblemXpRootOnly();
+
+ @Message(id = 318, value = "WebDAV client problem: XP-x64-SP2 is known not to
work with WebDAV Servlet")
+ String webDavClientProblemXp();
+
+ @Message(id = 319, value = "Unknown mode %s, must be one of: strict, authOnly,
strictAuthOnly")
+ IllegalArgumentException unknownAuthMode(String authMode);
+
+ @Message(id = 320, value = "Running CGI: bad header line: %s")
+ String cgiInvalidHeader(String header);
+
+ @Message(id = 321, value = "Error running CGI: %s")
+ String cgiException(String errorMessage);
+
+ @Message(id = 322, value = "Error closing header reader: %s")
+ String cgiExceptionClosingHeaderReader(String errorMessage);
+
+ @Message(id = 323, value = "Error closing output stream: %s")
+ String cgiExceptionClosingOutputStream(String errorMessage);
+
+ @Message(id = 324, value = "Interrupted waiting for stderr reader thread")
+ String cgiInterrupted();
+
+ @Message(id = 325, value = "Invalid HTTP status line: %s")
+ String cgiInvalidStatusLine(String line);
+
+ @Message(id = 326, value = "Invalid status code: %s")
+ String cgiInvalidStatusCode(String code);
+
+ @Message(id = 327, value = "Invalid status value: %s")
+ String cgiInvalidStatusValue(String value);
+
+ @Message(id = 328, value = "CGI stderr: %s")
+ String cgiErrorLogPrefix(String line);
+
+ @Message(id = 329, value = "Error reading error reader")
+ String cgiStderrErrror();
+
+ @Message(id = 330, value = "XSL transformer error")
+ String xslTransformerError();
+
+ @Message(id = 331, value = "Session %s expires processing failed")
+ String errorProcessingSessionExpires(String sessionId);
+
+ @Message(id = 332, value = "Error removing key %s")
+ String errorRemovingKey(String sessionId);
+
+ @Message(id = 333, value = "No nodes created")
+ String ssiParseNoNodes();
+
+ @Message(id = 334, value = "Extra nodes created")
+ String ssiParseExtraNodes();
+
+ @Message(id = 335, value = "Unused opp nodes exist")
+ String ssiParseUnusedNodes();
+
+ @Message(id = 336, value = "Couldn't exec file: %s")
+ String ssiExecFailed(String file);
+
+ @Message(id = 337, value = "#%s--Invalid attribute: %s")
+ String ssiInvalidAttribute(String directive, String attribute);
+
+ @Message(id = 338, value = "#flastmod--Couldn't get last modified for file:
%s")
+ String ssiFlastmodFailed(String file);
+
+ @Message(id = 339, value = "#fsize--Couldn't get size for file: %s")
+ String ssiFsizeFailed(String file);
+
+ @Message(id = 340, value = "Num chars can't be negative")
+ IllegalArgumentException invalidNumChars();
+
+ @Message(id = 341, value = "#include--Couldn't include file: %s")
+ String ssiIncludeFailed(String file);
+
+ @Message(id = 342, value = "#echo--Invalid encoding: %s")
+ String ssiEchoInvlidEncoding(String encoding);
+
+ @Message(id = 343, value = "[an error occurred while processing this
directive]")
+ String ssiDirectiveError();
+
+ @Message(id = 344, value = "Unknown encoding: %s")
+ String ssiUnknownEncoding(String encoding);
+
+ @Message(id = 345, value = "Unknown command: %s")
+ String ssiUnknownCommand(String command);
+
+ @Message(id = 346, value = "Error parsing command %s parameters")
+ String ssiParsingErrorNoParameters(String directive);
+
+ @Message(id = 347, value = "Parameter names count does not match parameter
values count on command %s")
+ String ssiParsingErrorBadParameterCount(String directive);
+
+ @Message(id = 348, value = "#set--no variable specified")
+ String ssiSetFailed();
+
+ @Message(id = 349, value = "Couldn't remove filename from path: %s")
+ String ssiFailedRemovingFilename(String path);
+
+ @Message(id = 350, value = "Normalization yielded null on path: %s")
+ String ssiFailedNormalization(String path);
+
+ @Message(id = 351, value = "A non-virtual path can't be absolute: %s")
+ String ssiInvalidNonVirtualPath(String path);
+
+ @Message(id = 352, value = "A non-virtual path can't contain '../':
%s")
+ String ssiInvalidNonVirtualPathWithTraversal(String path);
+
+ @Message(id = 353, value = "Couldn't get context for path: %s")
+ String ssiCannotGetContext(String path);
+
+ @Message(id = 354, value = "Couldn't remove context from path: %s")
+ String ssiCannotRemoveContext(String path);
+
+ @Message(id = 355, value = "Couldn't get request dispatcher for path:
%s")
+ String ssiCannotGetRequestDispatcher(String path);
+
+ @Message(id = 356, value = "Couldn't find file: %s")
+ String ssiCannotFindFile(String path);
+
+ @Message(id = 357, value = "Couldn't include file: %s")
+ String ssiServletIncludeFailed(String path);
+
+ @Message(id = 358, value = "Message digest non initialized")
+ IllegalStateException uninitializedMessageDigest();
+
}