Uploaded image for project: 'Cactus'
  1. Cactus
  2. CACTUS-123

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.1
    • 1.7
    • Framework
    • None
    • 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); }

      }

      Attachments

        1. nocontent.patch
          0.8 kB
          Maxwell Grender-Jones

        Activity

          People

            vmassol Vincent Massol
            themaniac Maxwell Grender-Jones
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: