deliveredtechnologies / rulebook

100% Java, Lambda Enabled, Lightweight Rules Engine with a Simple and Intuitive DSL
http://www.deliveredtechnologies.com
Apache License 2.0
716 stars 124 forks source link

ClassCastException in RuleAdapter for Wildcarded collections #174

Closed BrianDeacon closed 4 years ago

BrianDeacon commented 4 years ago

I made a PR with a fix that also describes the issue.

https://github.com/deliveredtechnologies/rulebook/pull/173

The short version is that RuleAdapter.mapFactsToProperties would hit an exception trying to hard-cast a genericized parameter type to Class<?> when it's really WildCardType or TypeVariable. The problem is caused by a @Given with no name that is a Collection type of a wildcarded parameter. e.g. Set<?> or Set<? extends Foo> or List<T>