You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/07/10 11:35:08 UTC
[tomcat] branch 8.5.x updated: Align AsyncCotextImpl with master
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new cadaf9d Align AsyncCotextImpl with master
cadaf9d is described below
commit cadaf9d0957db86e76af629fecf2da3314b57198
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jul 10 12:34:48 2019 +0100
Align AsyncCotextImpl with master
Improved i18n, use of ReflectiveOperationException, refactoring to
remove local InstanceManager reference
---
.../org/apache/catalina/core/AsyncContextImpl.java | 47 ++++++----------------
.../apache/catalina/core/LocalStrings.properties | 5 +++
.../catalina/core/LocalStrings_fr.properties | 15 ++++++-
3 files changed, 31 insertions(+), 36 deletions(-)
diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java b/java/org/apache/catalina/core/AsyncContextImpl.java
index 51198b2..4621644 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -19,9 +19,7 @@ package org.apache.catalina.core;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.naming.NamingException;
@@ -47,7 +45,6 @@ import org.apache.coyote.AsyncContextCallback;
import org.apache.coyote.RequestInfo;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.buf.UDecoder;
import org.apache.tomcat.util.res.StringManager;
@@ -78,7 +75,6 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
private long timeout = -1;
private AsyncEvent event = null;
private volatile Request request;
- private volatile InstanceManager instanceManager;
public AsyncContextImpl(Request request) {
if (log.isDebugEnabled()) {
@@ -108,8 +104,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
listener.fireOnComplete(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
- log.warn("onComplete() failed for listener of type [" +
- listener.getClass().getName() + "]", t);
+ log.warn(sm.getString("asyncContextImpl.onCompleteError",
+ listener.getClass().getName()), t);
}
}
} finally {
@@ -137,8 +133,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
listener.fireOnTimeout(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
- log.warn("onTimeout() failed for listener of type [" +
- listener.getClass().getName() + "]", t);
+ log.warn(sm.getString("asyncContextImpl.onTimeoutError",
+ listener.getClass().getName()), t);
}
}
request.getCoyoteRequest().action(
@@ -275,10 +271,9 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
check();
T listener = null;
try {
- listener = (T) getInstanceManager().newInstance(clazz.getName(),
- clazz.getClassLoader());
- } catch (InstantiationException | IllegalAccessException | NamingException |
- ClassNotFoundException e) {
+ listener = (T) context.getInstanceManager().newInstance(
+ clazz.getName(), clazz.getClassLoader());
+ } catch (ReflectiveOperationException | NamingException e) {
ServletException se = new ServletException(e);
throw se;
} catch (Exception e) {
@@ -297,7 +292,6 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
dispatch = null;
event = null;
hasOriginalRequestAndResponse = true;
- instanceManager = null;
listeners.clear();
request = null;
clearServletRequestResponse();
@@ -338,8 +332,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
listener.fireOnStartAsync(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
- log.warn("onStartAsync() failed for listener of type [" +
- listener.getClass().getName() + "]", t);
+ log.warn(sm.getString("asyncContextImpl.onStartAsyncError",
+ listener.getClass().getName()), t);
}
}
}
@@ -416,8 +410,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
listener.fireOnError(errorEvent);
} catch (Throwable t2) {
ExceptionUtils.handleThrowable(t2);
- log.warn("onError() failed for listener of type [" +
- listener.getClass().getName() + "]", t2);
+ log.warn(sm.getString("asyncContextImpl.onErrorError",
+ listener.getClass().getName()), t2);
}
}
}
@@ -508,20 +502,6 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
}
}
- private InstanceManager getInstanceManager() {
- if (instanceManager == null) {
- if (context instanceof StandardContext) {
- instanceManager = ((StandardContext)context).getInstanceManager();
- } else {
- instanceManager = new DefaultInstanceManager(null,
- new HashMap<String, Map<String, String>>(),
- context,
- getClass().getClassLoader());
- }
- }
- return instanceManager;
- }
-
private void check() {
if (request == null) {
// AsyncContext has been recycled and should not be being used
@@ -584,9 +564,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
try {
applicationDispatcher.dispatch(servletRequest, servletResponse);
- }catch (Exception x) {
- //log.error("Async.dispatch",x);
- throw new RuntimeException(x);
+ } catch (Exception e) {
+ throw new RuntimeException(sm.getString("asyncContextImpl.asyncDispachError"), e);
}
}
diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties
index 5d74093..ff89a88 100644
--- a/java/org/apache/catalina/core/LocalStrings.properties
+++ b/java/org/apache/catalina/core/LocalStrings.properties
@@ -92,8 +92,13 @@ aprListener.tooLateForSSLEngine=Cannot setSSLEngine: SSL has already been initia
aprListener.tooLateForSSLRandomSeed=Cannot setSSLRandomSeed: SSL has already been initialized
aprListener.wrongFIPSMode=Unexpected value of FIPSMode option of AprLifecycleListener: [{0}]
+asyncContextImpl.asyncDispachError=Error during asynchronous dispatch
asyncContextImpl.dispatchingStarted=Asynchronous dispatch operation has already been called. Additional asynchronous dispatch operation within the same asynchronous cycle is not allowed.
asyncContextImpl.noAsyncDispatcher=The dispatcher returned from the ServletContext does not support asynchronous dispatching
+asyncContextImpl.onCompleteError=onComplete() call failed for listener of type [{0}]
+asyncContextImpl.onErrorError=onError() call failed for listener of type [{0}]
+asyncContextImpl.onStartAsyncError=onStartAsync() call failed for listener of type [{0}]
+asyncContextImpl.onTimeoutError=onTimeout() call failed for listener of type [{0}]
asyncContextImpl.request.ise=It is illegal to call getRequest() after complete() or any of the dispatch() methods has been called
asyncContextImpl.requestEnded=The request associated with the AsyncContext has already completed processing.
asyncContextImpl.response.ise=It is illegal to call getResponse() after complete() or any of the dispatch() methods has been called
diff --git a/java/org/apache/catalina/core/LocalStrings_fr.properties b/java/org/apache/catalina/core/LocalStrings_fr.properties
index b0773aa..0405e55 100644
--- a/java/org/apache/catalina/core/LocalStrings_fr.properties
+++ b/java/org/apache/catalina/core/LocalStrings_fr.properties
@@ -23,8 +23,19 @@ applicationDispatcher.forward.ise=Impossible d''utiliser faire-suivre (forward)
applicationDispatcher.isUnavailable=La servlet [{0}] est actuellement indisponible
applicationDispatcher.serviceException="Servlet.service()" pour la servlet [{0}] a lancé une exception
-filterChain.filter=L''exécution du filtre (Filter) a lancé une exception
-filterChain.servlet=L''exécution de la servlet a lancé une exception
+asyncContextImpl.asyncDispachError=Erreur lors d'un dispatch asynchrone
+asyncContextImpl.dispatchingStarted=Une opération de dispatch asynchrone a déjà été appelée, plusieurs dispatch au cours d'un même cycle asynchrone n'est pas autorisé
+asyncContextImpl.noAsyncDispatcher=Le Servlet dispatcher retourné par le ServletContext ne supporte pas de dispatch asynchrone
+asyncContextImpl.onCompleteError=L''appel à onComplete() a échoué pour l''écouteur de type [{0}]
+asyncContextImpl.onErrorError=L''appel à onError() a échoué pour l''écouteur de type [{0}]
+asyncContextImpl.onStartAsyncError=L''appel à onStartAsync() a échoué pour l''écouteur de type [{0}]
+asyncContextImpl.onTimeoutError=L''appel à onTimeout() a échoué pour l''écouteur de type [{0}]
+asyncContextImpl.request.ise=Il est illégal d'appeler getRequest() après que complete() ou une autre des méthodes dispatch() ait été appelé
+asyncContextImpl.requestEnded=La requête associée avec l'AsyncContext est déjà terminée
+asyncContextImpl.response.ise=Il est illégal d'appeler getResponse() après que complete() ou n'importe laquelle des méthodes de dispatch a été appelée
+
+filterChain.filter=L'exécution du filtre (Filter) a lancé une exception
+filterChain.servlet=L'exécution de la servlet a lancé une exception
naming.bindFailed=Echec lors du liage à l''objet: [{0}]
naming.invalidEnvEntryType=L''entrée environnement [{0}] a un type invalide
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org