NullPointer exception while registering custom data table converter
See original GitHub issueSummary
NullPointer exception while registering custom data table converter
Current Behavior
Register the following table converter:
@DataTableType
public List convertDataTable(DataTable dataTable) {
return new ArrayList();
}
Define the following step:
@Given("table {}=")
public void setCustomDataTable(String name, List value) {
log.debug("Param {} = {}", name, value);
}
Create the following scenario:
Scenario: Compare empty data tables
Given table empty_table=
| test |
| |
Run the scenario:
Step failed
io.cucumber.core.exception.CucumberException: Could not convert arguments for step [table {}=] defined at 'com.cucumber.utils.context.stepdefs.ParamSteps.setCustomDataTable(java.lang.String,java.util.Map)'.
The details are in the stacktrace below.
at io.cucumber.core.runner.PickleStepDefinitionMatch.couldNotConvertArguments(PickleStepDefinitionMatch.java:108)
at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:52)
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:64)
at io.cucumber.core.runner.TestStep.run(TestStep.java:49)
at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:46)
at io.cucumber.core.runner.TestCase.run(TestCase.java:51)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:66)
at io.cucumber.core.runtime.Runtime.lambda$null$2(Runtime.java:100)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:243)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at io.cucumber.core.runtime.Runtime.lambda$run$3(Runtime.java:100)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1631)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:101)
at io.cucumber.core.cli.Main.run(Main.java:73)
at io.cucumber.core.cli.Main.main(Main.java:31)
Caused by: io.cucumber.datatable.CucumberDataTableException: 'java.util.List' could not transform
| test |
| |
at io.cucumber.datatable.DataTableType.transform(DataTableType.java:124)
at io.cucumber.datatable.DataTableTypeRegistryTableConverter.toListOrNull(DataTableTypeRegistryTableConverter.java:150)
at io.cucumber.datatable.DataTableTypeRegistryTableConverter.convertEntryKeys(DataTableTypeRegistryTableConverter.java:262)
at io.cucumber.datatable.DataTableTypeRegistryTableConverter.toMap(DataTableTypeRegistryTableConverter.java:216)
at io.cucumber.datatable.DataTableTypeRegistryTableConverter.convert(DataTableTypeRegistryTableConverter.java:73)
at io.cucumber.datatable.DataTable.convert(DataTable.java:357)
at io.cucumber.core.stepexpression.StepExpressionFactory.lambda$createExpression$4(StepExpressionFactory.java:63)
at io.cucumber.core.stepexpression.DataTableArgument.getValue(DataTableArgument.java:19)
at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:47)
... 24 more
Caused by: java.lang.NullPointerException
at io.cucumber.java.AbstractDatatableElementTransformerDefinition.replaceEmptyPatternsWithEmptyString
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
java - NullPointerException when trying to define a custom ...
the problem is only with the TimeZone object so I have to use a converter, which is not ideal. map().setTimeZone(source.getTimeZone().getID()); ...
Read more >OES11g - Getting Null Pointer Exception When Using Custom ...
Getting Null exception, after decide instruction, when using Custom Function to get attributes. Seeing the next exception in log: Nov 8, 2013 10 ......
Read more >Nullpointer exception - OpenText Forums
All, I am able to generate reports from eclipse/tomcat workspace. The same deployed in server (unix) enviroment but I am getting exception while...
Read more >"java.lang.NullPointerException" while validating an ORS after ...
When creating custom indexes on the Master Data Management (MDM) landing table using the Register Custom Index request, the following error ...
Read more >How to Fix and Avoid NullPointerException in Java - Rollbar
Table of Contents ... The java.lang.NullPointerException is a runtime exception in Java that occurs when a variable is accessed which is not ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Datatable.asMaps()
has a value collision when null keys are used. Not actually an NPE but based on same assumption as the table entry NPE.Actually, indeed I was doing something wrong. Inside my project I had some business code that was executing, and somewhere it threw a null pointer exception. Indeed, relevant stacktrace of my code was somehow swallowed.That’s why I first thought it was related to cucumber library. However, this issue is fixed.
Thanks for the replies.