Cactus
  1. Cactus
  2. CACTUS-123

Failure to write to the response having set the Status -> NullPointer

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.7
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Run under maven cactus plugin (1.6.1, on 1.0rc3) , on a gentoo machine. Java 1.4.2.04, Tomcat 4.1.30

      Description

      In the example below, a NullPointerException is thrown within Cactus before the endNoContentMethod is reached. However, the 'SomeContent' test passes without incident.

      Testcase: testNoContent took 0.301 sec
      [cactus] Caused an ERROR
      [cactus] null
      [cactus] java.lang.NullPointerException
      [cactus] at org.apache.cactus.internal.client.connector.http.AutoReadHttpURLConnection.copy(AutoReadHttpURLConnection.java:187)

      import org.apache.cactus.WebRequest;
      import org.apache.cactus.WebResponse;
      import org.apache.cactus.ServletTestCase;

      import javax.servlet.http.HttpServletResponse;

      import java.io.IOException;

      public class CactusTest extends ServletTestCase
      {
      public void testNoContent()

      { response.setStatus(HttpServletResponse.SC_NO_CONTENT); }

      public void endNoContent(WebResponse webResponse)

      { assertEquals(webResponse.getStatusCode(), 204); }

      public void testSomeContent() throws IOException
      { response.setStatus(HttpServletResponse.SC_NO_CONTENT); response.getWriter().println(); }

      public void endSomeContent(WebResponse webResponse)
      { assertEquals(webResponse.getStatusCode(), 204); }

      }

      1. nocontent.patch
        0.8 kB
        Maxwell Grender-Jones

        Activity

          People

          • Assignee:
            Vincent Massol
            Reporter:
            Maxwell Grender-Jones
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development