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

        Maxwell Grender-Jones created issue -
        Hide
        Maxwell Grender-Jones added a comment -

        This fixes the problem (it's a simple !=null check )
        If this is sufficient to get me added to contributors, pse can you do so

        Thanks

        Show
        Maxwell Grender-Jones added a comment - This fixes the problem (it's a simple !=null check ) If this is sufficient to get me added to contributors, pse can you do so Thanks
        Maxwell Grender-Jones made changes -
        Field Original Value New Value
        Attachment nocontent.patch [ 14636 ]
        Hide
        Vincent Massol added a comment -

        Applied. Thanks! I've added you to the changes.xml file.

        Show
        Vincent Massol added a comment - Applied. Thanks! I've added you to the changes.xml file.
        Vincent Massol made changes -
        Fix Version/s 1.7 [ 10693 ]
        Assignee Vincent Massol [ vmassol ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]

          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