NPE in BindBeanFactory when no getter #61

lorrin opened this Issue Apr 5, 2013 · 2 comments


None yet

2 participants

lorrin commented Apr 5, 2013

When using @BindBean and a POJO that has setters with no corresponding getters, I get NullPointerExceptions. Trace below. I think what's going on is that BindBeanFactory loops through the property descriptors and doesn't check for null in the result of prop.getReadMethod(). But per PropertyDescriptor JavaDoc, getReadMethod "may return null if the property can't be read." It looks like it simply skipping over any null results would achieve the desired result.

java.lang.IllegalStateException: unable to bind bean properties
    at org.skife.jdbi.v2.sqlobject.BindBeanFactory$1.bind(
    at org.skife.jdbi.v2.sqlobject.BindBeanFactory$1.bind(
    at org.skife.jdbi.v2.sqlobject.Bindifier.bind(
    at org.skife.jdbi.v2.sqlobject.CustomizingStatementHandler.applyBinders(
    at org.skife.jdbi.v2.sqlobject.UpdateHandler.invoke(
    at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(
    at org.skife.jdbi.v2.sqlobject.SqlObject$1.intercept(
    at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$a7db5f40.record(<generated>)
Caused by: java.lang.NullPointerException
    at org.skife.jdbi.v2.sqlobject.BindBeanFactory$1.bind(
    ... 40 more
@stevenschlansker stevenschlansker added a commit to stevenschlansker/jdbi that referenced this issue Apr 5, 2013
@stevenschlansker stevenschlansker Test case for #61: cause NPE in BindBeanFactory if there are writable…
… but not readable properties

Hope this fixes your issue!

lorrin commented Apr 5, 2013

Excellent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment