Issue Details (XML | Word | Printable)

Key: CACTUS-123
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vincent Massol
Reporter: Maxwell Grender-Jones
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cactus

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

Created: 01/Jun/04 05:14 PM   Updated: 19/Jun/04 03:12 PM
Return to search
Component/s: Framework
Affects Version/s: 1.6.1
Fix Version/s: 1.7

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works nocontent.patch 2004-06-17 10:53 AM Maxwell Grender-Jones 0.8 kB
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

Resolution Date: 19/Jun/04 03:12 PM


 Description  « Hide
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);
}

}

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Maxwell Grender-Jones added a comment - 17/Jun/04 10:53 AM
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 - 17/Jun/04 10:53 AM
Field Original Value New Value
Attachment nocontent.patch [ 14636 ]
Repository Revision Date User Message
ASF #239010 Sat Jun 19 15:10:53 UTC 2004 vmassol <action dev="VMA" type="fix" issue="CACTUS-123" due-to="Maxwell Grender-Jones">
          Cactus was failing with a <code>NullPointerException</code> if the
          response was not returning any output stream (which happens if
          <code>response.setStatus(HttpServletResponse.SC_NO_CONTENT)</code> is
          called for example).
        </action>
Files Changed
MODIFY /jakarta/cactus/trunk/documentation/docs/xdocs/changes.xml
MODIFY /jakarta/cactus/trunk/framework/src/java/share-12-13-14/org/apache/cactus/internal/client/connector/http/AutoReadHttpURLConnection.java
MODIFY /jakarta/cactus/trunk/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/servlet/unit/TestHttpResponse.java

Vincent Massol added a comment - 19/Jun/04 03:12 PM
Applied. Thanks! I've added you to the changes.xml file.

Vincent Massol made changes - 19/Jun/04 03:12 PM
Assignee Vincent Massol [ vmassol ]
Status Open [ 1 ] Closed [ 6 ]
Resolution Fixed [ 1 ]
Fix Version/s 1.7 [ 10693 ]