[ grinder-Bugs-3525156 ] Null pointer exeception when posting form data

SourceForge.net <[email protected]> Tue, 18 Sep 2012 14:56:45 -0700
Newsgroups gmane.comp.java.grinder.devel
Message-ID <[email protected]>
Bugs item #3525156, was opened at 2012-05-09 09:17
Message generated for change (Settings changed) made by philipa
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=3525156&group_id=18598

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: HTTP Plugin
Group: None
>Status: Closed
Resolution: Fixed
Priority: 3
Private: No
Submitted By: Ouray Viney (oviney)
Assigned to: Philip Aston (philipa)
Summary: Null pointer exeception when posting form data

Initial Comment:
Upgraded my Grinder 3.4 to 3.8 and got the following exception:


2012-05-09 11:22:56,663 ERROR lingrndctl-0 thread-15 [ run-0 ]: Aborted run: Java exception calling TestRunner
net.grinder.scriptengine.jython.JythonScriptExecutionException: Java exception calling TestRunner
        result = getCommRateRequest.POST(self.URI, self.getCommRateXMLPayload,
        File "/opt/home/testusr1/est/bdt1.1/bin/./lingrndctl-file-store/current/ca/innovapost/test/scenarios/tpoGetCommRate.py", line 108, in getCommRate
        getCommRateResponse = self.getCommRate()
        File "/opt/home/testusr1/est/bdt1.1/bin/./lingrndctl-file-store/current/ca/innovapost/test/scenarios/tpoGetCommRate.py", line 124, in __call__
        self.testRunner()
        File "/opt/home/testusr1/est/bdt1.1/bin/./lingrndctl-file-store/current/ca/innovapost/test/resources/../scenarios/tpoPerformanceScenario1x.py", line 111, in __call__
java.lang.NullPointerException: null
        at net.grinder.plugin.http.HTTPRequest.mergeArrays(HTTPRequest.java:184) ~[grinder-http-3.8.jar:na]
        at net.grinder.plugin.http.HTTPRequest.mergeHeaders(HTTPRequest.java:197) ~[grinder-http-3.8.jar:na]
        at net.grinder.plugin.http.HTTPRequest.access$000(HTTPRequest.java:99) ~[grinder-http-3.8.jar:na]
        at net.grinder.plugin.http.HTTPRequest$AbstractRequest.<init>(HTTPRequest.java:1181) ~[grinder-http-3.8.jar:na]
        at net.grinder.plugin.http.HTTPRequest$8.<init>(HTTPRequest.java:902) ~[grinder-http-3.8.jar:na]
        at net.grinder.plugin.http.HTTPRequest.POST(HTTPRequest.java:902) ~[grinder-http-3.8.jar:na]
        at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.6.0_13]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.6.0_13]
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186) ~[jython.jar:na]
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204) ~[jython.jar:na]
        at org.python.core.PyObject.__call__(PyObject.java:441) ~[jython.jar:na]
        at org.python.core.PyObject.__call__(PyObject.java:447) ~[jython.jar:na]
        at org.python.core.PyMethod.__call__(PyMethod.java:154) ~[jython.jar:na]

This problem was fixed in the past - here is the original post http://permalink.gmane.org/gmane.comp.java.grinder.user/8086

----------------------------------------------------------------------

Comment By: Philip Aston (philipa)
Date: 2012-05-10 23:31

Message:
Fixed for next release:
http://grinder.git.sourceforge.net/git/gitweb.cgi?p=grinder/grinder;a=commitdiff;h=6241641b6233956699841ae578515f5115007119

----------------------------------------------------------------------

Comment By: Ouray Viney (oviney)
Date: 2012-05-10 22:11

Message:
Yes, I agree with your suggestion re: throwing an NPE with more specific
details.

----------------------------------------------------------------------

Comment By: Philip Aston (philipa)
Date: 2012-05-10 08:11

Message:
It could be a regression caused by the 3.7 change.

Anyway, yes, I agree the grinder could handle it better. I don't think it
should allow the (None, blah), because there's nothing to be done with it.
Would throwing a NullPointerException with a more specific message, e.g.
"NVPair name is null" be more useful.

----------------------------------------------------------------------

Comment By: Ouray Viney (oviney)
Date: 2012-05-10 08:06

Message:
Hi Again:

Phil, I think you were right, *AGAIN*!

I reviewed the source code for the said script.  I noticed the following
line:

        # Send the request over the wire        
        result = getCommRateRequest.POST(self.URI,
self.getCommRateXMLPayload,
                (None,))

I adjusted that to:

        # Send the request over the wire        
        result = getCommRateRequest.POST(self.URI,
self.getCommRateXMLPayload)

Retried with the Grinder 3.8 jars and this time had no issues.  So, if this
is a script error, then:

1) Grinder 3.4 was swallowing the NPE
2) Grinder 3.8 was no longer catching the NPE

I supposed it would be good if Grinder 3.8 gave a more user friendly
exception message =).

Errors like these are easy to  accidentally introduce as the "grinderstone"
eclipse plugin doesn't check these types of programmatic errors.  I am open
to any suggestions on how to improve checking of these types of errors.

Thanks,

Ouray

----------------------------------------------------------------------

Comment By: Ouray Viney (oviney)
Date: 2012-05-10 07:57

Message:
Hi:

Interesting.  This same script runs fine in Grinder 3.4 with the said
patch.  That is why I thought it *might* be a regression bug.

I just ran this with Grinder 3.4 (with the patch included in the class
path).

Here is the POST:


POST https://foobart.com:5000/webservice/RateShoppingService HTTP/1.1
Host: foobart.com:5000
Connection: Keep-Alive, TE
TE: trailers
User-Agent: Jakarta Commons-HttpClient/3.1
Accept-Language: en-CA
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
Content-length: 2175


<soapenv:Envelope
xmlns:rat="http://foobart.com/ebusiness/RateShoppingServiceWrapper"
xmlns:rat1="http://foobart.com/ebusiness/RateShoppingService"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<soapenv:Header>
		<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
			<wsse:UsernameToken wsu:Id="UsernameToken-1"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
				<wsse:Username>FOOBART</wsse:Username>
				<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">FOOBART</wsse:Password>
				<wsse:Nonce
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">ABCY77864</wsse:Nonce>
				<wsu:Created>2012-01-25T18:25:53.729Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</soapenv:Header>
	<soapenv:Body>
		<rat:getCommRate>
			<rat:request>
				<!--1 or more repetitions:-->
				<rat1:MailingScenario>
					<rat1:ChannelTypeCode>COMMERCIAL</rat1:ChannelTypeCode>
					<rat1:AutomationDiscountCode>EORDER2</rat1:AutomationDiscountCode>
					<rat1:MailingDate>2011-10-10</rat1:MailingDate>
					<rat1:Quantity>10000</rat1:Quantity>
					<rat1:Option Code="TRANSP"/>
					<rat1:MailItemDetails>
						<rat1:Weight>23</rat1:Weight>
						<!--Optional:-->
						<rat1:DimensionalCharacteristics>
							<!--You have a CHOICE of the next 2 items at this level-->
							<rat1:SizeClassCode>OS1</rat1:SizeClassCode>
						</rat1:DimensionalCharacteristics>
					</rat1:MailItemDetails>
					<rat1:ProductServiceID>DOM.UA</rat1:ProductServiceID>
					<rat1:ProvinceOfDeposit>ON</rat1:ProvinceOfDeposit>
					<!--Optional:-->
					<rat1:PrepTypeCode>LC</rat1:PrepTypeCode>
				</rat1:MailingScenario>
			</rat:request>
		</rat:getCommRate>
	</soapenv:Body>
</soapenv:Envelope>


----------------------------------------------------------------------

Comment By: Philip Aston (philipa)
Date: 2012-05-10 07:33

Message:
This has similar symptoms to the previous bug (3006631) that was fixed in
3.7, but is different, rather than a regression from 3.7. The previous bug
was specific to multipart handling. I can see from your stack trace that
you are not posting multipart data, so I've corrected the bug subject.

Can you add the POST that caused this? As far as I can see, the header
array your supplying is invalid; one of the NVPairs has a null name.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=3525156&group_id=18598

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/