Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/477#discussion_r92826864
--- Diff:
utils/common/src/test/java/org/apache/brooklyn/util/javalang/coerce/TypeCoercionsTest.java
---
@@ -344,6 +344,59 @@ public void testFrom() {
}
@Test
+ public void testFromThrowingException() {
+ String expectedGenericErr = "Cannot coerce type class " +
String.class.getName() + " to " +
WithFromThrowingException.class.getCanonicalName();
+ String expectedSpecificErr = "Simulating problem in fromString";
+
+ try {
+ coercer.coerce("myval", WithFromThrowingException.class);
+ Asserts.shouldHaveFailedPreviously();
+ } catch (ClassCoercionException e) {
+ Asserts.expectedFailureContains(e, expectedGenericErr,
expectedSpecificErr);
+ }
+
+ try {
+ coercer.tryCoerce("myval",
WithFromThrowingException.class).get();
+ Asserts.shouldHaveFailedPreviously();
+ } catch (ClassCoercionException e) {
+ Asserts.expectedFailureContains(e, expectedGenericErr,
expectedSpecificErr);
+ }
+ }
+
+ // TODO Asserting this undesirable behaviur, to preserve backwards
compatibility!
+ // Would much prefer that we fail-fast. However, I worry that some
entity's jave declared
--- End diff --
typo `jave`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---