Return-Path: Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: (qmail 79818 invoked from network); 1 Apr 2009 17:46:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Apr 2009 17:46:30 -0000 Received: (qmail 51477 invoked by uid 500); 1 Apr 2009 17:46:30 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 51425 invoked by uid 500); 1 Apr 2009 17:46:29 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 51411 invoked by uid 99); 1 Apr 2009 17:46:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2009 17:46:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2009 17:46:25 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7BB63234C045 for ; Wed, 1 Apr 2009 10:46:03 -0700 (PDT) Message-ID: <1700735175.1238607963495.JavaMail.jira@brutus> Date: Wed, 1 Apr 2009 10:46:03 -0700 (PDT) From: "Musachy Barroso (JIRA)" To: issues@struts.apache.org Subject: [jira] Commented: (WW-3068) ExecuteAndWaitInterceptor org.apache.struts2.interceptor.ExecuteAndWaitInterceptor.doIntercept(ExecuteAndWaitInterceptor.java:256) In-Reply-To: <2061226723.1238454663477.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 2265bf7ad70cb93affdfde3e15287371 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/struts/browse/WW-3068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45813#action_45813 ] Musachy Barroso commented on WW-3068: ------------------------------------- The problem is that configuration is now unmodifiable, so adding a "fake" result to the result config map will cause an exception to be thrown. > ExecuteAndWaitInterceptor org.apache.struts2.interceptor.ExecuteAndWaitInterceptor.doIntercept(ExecuteAndWaitInterceptor.java:256) > ----------------------------------------------------------------------------------------------------------------------------------- > > Key: WW-3068 > URL: https://issues.apache.org/struts/browse/WW-3068 > Project: Struts 2 > Issue Type: Bug > Environment: Struts-2.1.6 > TC 6.0.14 > JDK 1.6.0_10 > > Subject: Re: ExecuteAndWaitInterceptor not working (2.1.6) > > > execAndWait in 2.1.6 gives the following exception when it kicks in: (code pasted below) > > > > > > > > > java.lang.UnsupportedOperationException > > > ??? java.util.Collections$UnmodifiableMap.put(Collections.java:1285) > > > ??? org.apache.struts2.interceptor.ExecuteAndWaitInterceptor.doIntercept(ExecuteAndWaitInterceptor.java:256) > > > Reporter: Martin Gainty > > public static final String WAIT = "wait"; > org.apache.struts2.interceptor.ExecuteAndWaitInterceptor.java > ............. > protected String doIntercept(ActionInvocation actionInvocation) throws Exception { > .............. > //sync on the real HttpSession as the session from the context is a wrap that is created > //on every request > synchronized (httpSession) > { > BackgroundProcess bp = (BackgroundProcess) session.get(KEY + name); > if ((!executeAfterValidationPass || secondTime) && bp == null) > { > bp = getNewBackgroundProcess(name, actionInvocation, threadPriority); > session.put(KEY + name, bp); > performInitialDelay(bp); // first time let some time pass before showing wait page > secondTime = false; > } > if ((!executeAfterValidationPass || !secondTime) && bp != null && !bp.isDone()) { > actionInvocation.getStack().push(bp.getAction()); > Map results = proxy.getConfig().getResults(); > if (!results.containsKey(WAIT)) { > LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " + > "Defaulting to a plain built-in wait page. It is highly recommend you " + > "provide an action-specific or global result named '" + WAIT + > "'! This requires FreeMarker support and won't work if you don't have it installed"); > // no wait result? hmm -- let's try to do dynamically put it in for you! > ResultConfig rc = new ResultConfig.Builder(WAIT, "org.apache.struts2.views.freemarker.FreemarkerResult") > .addParams(Collections.singletonMap("location", "/org/apache/struts2/interceptor/wait.ftl")) > .build(); > /************ABOVE CODE causes abend************/ > results.put(WAIT, rc); > //http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html#put(java.lang.Object,%20java.lang.Object) > } > if (TokenHelper.getToken() != null) { > session.put(TokenHelper.getTokenName(), TokenHelper.getToken()); > } > return WAIT; > } else if ((!executeAfterValidationPass || !secondTime) && bp != null && bp.isDone()) { > session.remove(KEY + name); > actionInvocation.getStack().push(bp.getAction()); > // if an exception occured during action execution, throw it here > if (bp.getException() != null) { > throw bp.getException(); > } > return bp.getResult(); > } else { > // this is the first instance of the interceptor and there is no existing action > // already run in the background, so let's just let this pass through. We assume > // the action invocation will be run in the background on the subsequent pass through > // this interceptor > return actionInvocation.invoke(); > } > } > } > where > Collections.singletonMap("location", "/org/apache/struts2/interceptor/wait.ftl")) > public static Map singletonMap(K key, V value) { > 3343 return new SingletonMap(key, value); > 3344 } > //Here is applicable SingletonMap > 3349 private static class SingletonMap > 3350 extends AbstractMap > 3351 implements Serializable { > 3352 private static final long serialVersionUID = -6979724477215052911L; > 3353 > 3354 private final K k; > 3355 private final V v; > 3356 > 3357 SingletonMap(K key, V value) { > 3358 k = key; > 3359 v = value; > 3360 } > //UnsupportedOperation details > The "destructive" methods contained in this interface, that is, the methods that modify the map on which they operate, are specified to throw UnsupportedOperationException if this map does not support the operation. If this is the case, these methods may, but are not required to, throw an UnsupportedOperationException if the invocation would have no effect on the map. For example, invoking the #putAll(Map) method on an unmodifiable map may, but is not required to, throw the exception if the map whose mappings are to be "superimposed" is empty. > //which calls Builder > http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/config/entities/ResultConfig.Builder.html > //which calls addparams method which takes 2 String placeholders for Map > ResultConfig.Builder addParams(Map params) > //the code calls singletonMap which is an immutable Map > 3332 /** > 3333 * Returns an immutable map, mapping only the specified key to the > 3334 * specified value. The returned map is serializable. > 3335 * > 3336 * @param key the sole key to be stored in the returned map. > 3337 * @param value the value to which the returned map maps key. > 3338 * @return an immutable map containing only the specified key-value > 3339 * mapping. > 3340 * @since 1.3 > 3341 */ > 3342 public static Map singletonMap(K key, V value) { > 3343 return new SingletonMap(key, value); > 3344 } > so the fix would be to replace > Collections.SingletonMap > .addParams(Collections.singletonMap("location", "/org/apache/struts2/interceptor/wait.ftl")) > with 2 plain strings for addParams e.g. > .addParams("location", "/org/apache/struts2/interceptor/wait.ftl")) > ? > Martin -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.