vmassol     01/06/17 06:39:13

  Modified:    cactus/src/framework/share/org/apache/commons/cactus/server
                        JspTestCaller.java
  Added:       cactus/src/framework/share/org/apache/commons/cactus/server
                        ResultHolder.java
  Log:
  correction of bug #1612
  
  Revision  Changes    Path
  1.3       +11 -2     
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/server/JspTestCaller.java
  
  Index: JspTestCaller.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/server/JspTestCaller.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JspTestCaller.java        2001/04/14 15:47:30     1.2
  +++ JspTestCaller.java        2001/06/17 13:39:13     1.3
  @@ -161,6 +161,15 @@
       {
           ServletTestResult result = null;
   
  +        // Reset TEST_RESULTS to a new results holder to prevent premature
  +        // requests for results from seeing either no results or old results
  +        ResultHolder holder = new ResultHolder();
  +        theObjects.m_Config.getServletContext().setAttribute(TEST_RESULTS, holder);
  +
  +        // From this point forward, any thread trying to access the result
  +        // stored in the holder, itself stored in the application scope, will
  +        // block and wait until a result is set.
  +
           try {
   
               // Extract from the HTTP request the test class name and method to call.
  @@ -195,8 +204,8 @@
   
           }
   
  -        // Save the test result.
  -        theObjects.m_Config.getServletContext().setAttribute(TEST_RESULTS, result);
  +        // Set the test result.
  +        holder.setResult(result);
   
       }
   
  
  
  
  1.1                  
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/server/ResultHolder.java
  
  Index: ResultHolder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.cactus.server;
  
  import org.apache.commons.cactus.*;
  
  /**
   * Provides synchronized access to test results to prevent the
   * request for servlet results being processed before the test
   * servlet has written the results.
   */
  class ResultHolder
  {
      private ServletTestResult result;
  
      public synchronized void setResult(ServletTestResult r)
      {
          result = r;
          notifyAll();
      }
  
      public synchronized ServletTestResult getResult()
      {
          while(result == null) {
              try {
                  wait();
              } catch(InterruptedException ie) {
                  throw new RuntimeException("Unexpected 'InterruptedException' 
exception");
              }
          }
          return result;
      }
  }
  
  
  

Reply via email to