[CLJ-724] bean throws NPE when key doesn't exist Created: 22/Jan/11 Updated: 05/Apr/11 Resolved: 05/Apr/11
|Affects Version/s:||Release 1.3|
|Patch:||Code and Test|
The result of (bean obj) throws a NullPointerException when passed in a key that doen't exist. I think instead it should return nil to be consistent with maps and records - or at least the error message should be more explicit.
|Comment by Alexander Redington [ 25/Mar/11 9:51 AM ]|
The proxy returned by (bean) performs a bare invocation on the getter method without checking if it exists first. Fixed the bug by adding a long-hand constantly as the missing value for the map fetch. (constantly is not defined yet when core_proxy is read.)
Also renamed the property map defined in bean to 'propmap' instead of 'pmap' to avoid ambiguity with clojure.core/pmap
|Comment by Stuart Halloway [ 05/Apr/11 8:46 PM ]|
Beans aren't maps, and without any discussion of motivation it isn't clear that this change is an improvement.
If bean was more consumer-friendly, people might use it in production more often. Don't. Reflection is slow. If there is a motivating use case other than REPL exploration for converting beans to maps, let's design something more performant targeted to that case.