I wanted to confirm this behavior before filing a bug report. I'm
running JMeter 2.6 on Windows 7 x64. My service accepts a PUT request
with a file as the body. According to the documentation this is
accomplished by setting up an HTTP Sampler with no parameters and one
unnamed file to include with the request.

When I run this however I get a NullPointerException:

java.lang.NullPointerException: charsetName at
java.lang.String.<init>(Unknown Source) at
java.lang.String.<init>(Unknown Source) at
org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sendPutData(HTTPHC4Impl.java:1067)
at 
org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:274)
at 
org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at 
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1054)
at 
org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1043)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:416)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:271)
at java.lang.Thread.run(Unknown Source)

After some searching to no avail I checked out the source code and
added some logging. The error occurs in HTTPHC4Impl.java:

            // If the request entity is repeatable, we can send it first to
            // our own stream, so we can return it
            if(put.getEntity().isRepeatable()) {
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                put.getEntity().writeTo(bos);
                bos.flush();
                // We get the posted bytes using the charset that was
used to create them
                putBody.append(new String(bos.toByteArray(),
                        (String)
putParams.getParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET)));
                bos.close();
            }

getParameter() is being called on a parameter that is only set if
getSendParameterValuesAsPostBody() is true. I copy/pasted that section
of code into the if statement above (if (!hasArguments() &&
getSendFileAsPostBody()) and ran the build. It seemed to work fine as
long as I specified a content-encoding (in my case, UTF-8).

I can submit a patch if requested, but be warned I'm not really up to
date with the coding standards used in apache projects.

Thanks for your consideration!

Joe

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to