Skip to content

Commit 58e57b0

Browse files
committed
Merge #658. Update History.md.
2 parents 5df09f8 + 6fe3fb5 commit 58e57b0

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

History.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [1-1-6-SNAPSHOT (Git master)](https://github.com/cucumber/cucumber-jvm/compare/v1.1.5...master)
22

3+
* [Core] More precise handling of the XStream errors. ([#657](https://github.com/cucumber/cucumber-jvm/issues/657), [#658](https://github.com/cucumber/cucumber-jvm/pull/658) Mykola Gurov)
34
* [Core] Performance improvement: URLOutputStream can write several bytes, not just one-by-one. ([#654](https://github.com/cucumber/cucumber-jvm/issues/654) Aslak Hellesøy)
45
* [Core] Add support for transposed tables. ([#382](https://github.com/cucumber/cucumber-jvm/issues/382), [#635](https://github.com/cucumber/cucumber-jvm/pull/635), Roberto Lo Giacco)
56
* [Examples] Fixed concurrency bugs in Webbit Selenium example (Aslak Hellesøy)

core/src/main/java/cucumber/runtime/table/TableConverter.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,14 @@ private <T> List<T> toListOfComplexType(DataTable dataTable, Class<T> itemType)
107107
return Collections.unmodifiableList((List<T>) xStream.unmarshal(reader));
108108
} catch (AbstractReflectionConverter.UnknownFieldException e) {
109109
throw new CucumberException(e.getShortMessage());
110+
} catch (AbstractReflectionConverter.DuplicateFieldException e) {
111+
throw new CucumberException(e.getShortMessage());
110112
} catch (ConversionException e) {
111-
throw new CucumberException(String.format("Can't assign null value to one of the primitive fields in %s. Please use boxed types.", e.get("class")));
113+
if (e.getCause() instanceof NullPointerException) {
114+
throw new CucumberException(String.format("Can't assign null value to one of the primitive fields in %s. Please use boxed types.", e.get("class")));
115+
} else {
116+
throw new CucumberException(e);
117+
}
112118
}
113119
}
114120

core/src/test/java/cucumber/runtime/table/ToDataTableTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ public void gives_a_nice_error_message_when_primitive_field_is_null() {
8181
}
8282
}
8383

84+
@Test
85+
public void gives_a_meaningfull_error_message_when_field_is_repeated() {
86+
try {
87+
tc.toList(UserPojo.class, TableParser.parse("" +
88+
"| credits | credits |\n" +
89+
"| 5 | 5 |\n" +
90+
"", PARAMETER_INFO)
91+
);
92+
fail();
93+
} catch (CucumberException e) {
94+
assertEquals("Duplicate field credits", e.getMessage());
95+
}
96+
}
97+
8498
@Test
8599
public void converts_list_of_beans_to_table_with_explicit_columns() {
86100
List<UserPojo> users = tc.toList(UserPojo.class, personTable());

0 commit comments

Comments
 (0)