mirror of https://github.com/apache/nifi.git
NIFI-3403 - Fix NPE in InvokeHTTP
Signed-off-by: Mike Moser <mosermw@apache.org> This closes #1494
This commit is contained in:
parent
4e4d14f86f
commit
2e1b87fa43
|
@ -863,7 +863,7 @@ public final class InvokeHTTP extends AbstractProcessor {
|
||||||
// iterate through the flowfile attributes, adding any attribute that
|
// iterate through the flowfile attributes, adding any attribute that
|
||||||
// matches the attributes-to-send pattern. if the pattern is not set
|
// matches the attributes-to-send pattern. if the pattern is not set
|
||||||
// (it's an optional property), ignore that attribute entirely
|
// (it's an optional property), ignore that attribute entirely
|
||||||
if (regexAttributesToSend != null) {
|
if (regexAttributesToSend != null && requestFlowFile != null) {
|
||||||
Map<String, String> attributes = requestFlowFile.getAttributes();
|
Map<String, String> attributes = requestFlowFile.getAttributes();
|
||||||
Matcher m = regexAttributesToSend.matcher("");
|
Matcher m = regexAttributesToSend.matcher("");
|
||||||
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
||||||
|
|
|
@ -448,6 +448,35 @@ public abstract class TestInvokeHttpCommon {
|
||||||
bundle1.assertAttributeEquals("Content-Type", "text/plain;charset=iso-8859-1");
|
bundle1.assertAttributeEquals("Content-Type", "text/plain;charset=iso-8859-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoInputWithAttributes() throws Exception {
|
||||||
|
addHandler(new GetOrHeadHandler());
|
||||||
|
|
||||||
|
runner.setProperty(InvokeHTTP.PROP_URL, url + "/status/200");
|
||||||
|
runner.setProperty(InvokeHTTP.PROP_METHOD, "GET");
|
||||||
|
runner.setProperty(InvokeHTTP.PROP_ATTRIBUTES_TO_SEND, "myAttribute");
|
||||||
|
runner.setIncomingConnection(false);
|
||||||
|
runner.setNonLoopConnection(false);
|
||||||
|
|
||||||
|
runner.run();
|
||||||
|
|
||||||
|
runner.assertTransferCount(InvokeHTTP.REL_SUCCESS_REQ, 0);
|
||||||
|
runner.assertTransferCount(InvokeHTTP.REL_RESPONSE, 1);
|
||||||
|
runner.assertTransferCount(InvokeHTTP.REL_RETRY, 0);
|
||||||
|
runner.assertTransferCount(InvokeHTTP.REL_NO_RETRY, 0);
|
||||||
|
runner.assertTransferCount(InvokeHTTP.REL_FAILURE, 0);
|
||||||
|
runner.assertPenalizeCount(0);
|
||||||
|
|
||||||
|
// expected in response
|
||||||
|
// status code, status message, all headers from server response --> ff attributes
|
||||||
|
// server response message body into payload of ff
|
||||||
|
final MockFlowFile bundle1 = runner.getFlowFilesForRelationship(InvokeHTTP.REL_RESPONSE).get(0);
|
||||||
|
bundle1.assertContentEquals("/status/200".getBytes("UTF-8"));
|
||||||
|
bundle1.assertAttributeEquals(InvokeHTTP.STATUS_CODE, "200");
|
||||||
|
bundle1.assertAttributeEquals(InvokeHTTP.STATUS_MESSAGE, "OK");
|
||||||
|
bundle1.assertAttributeEquals("Content-Type", "text/plain;charset=iso-8859-1");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoInputFail() throws Exception {
|
public void testNoInputFail() throws Exception {
|
||||||
addHandler(new GetOrHeadHandler());
|
addHandler(new GetOrHeadHandler());
|
||||||
|
|
Loading…
Reference in New Issue