Permalink
Browse files

Protect against properties that can be written but not read. Fixes #61.

  • Loading branch information...
1 parent 8f0bd27 commit 4674618a2bfb91ef9f4dbaeddb447715b727bf9a @stevenschlansker stevenschlansker committed Apr 5, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/main/java/org/skife/jdbi/v2/sqlobject/BindBeanFactory.java
@@ -6,6 +6,7 @@
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
class BindBeanFactory implements BinderFactory
{
@@ -27,7 +28,10 @@ public void bind(SQLStatement q, BindBean bind, Object arg)
BeanInfo infos = Introspector.getBeanInfo(arg.getClass());
PropertyDescriptor[] props = infos.getPropertyDescriptors();
for (PropertyDescriptor prop : props) {
- q.bind(prefix + prop.getName(), prop.getReadMethod().invoke(arg));
+ Method readMethod = prop.getReadMethod();
+ if (readMethod != null) {
+ q.bind(prefix + prop.getName(), readMethod.invoke(arg));
+ }
}
}
catch (Exception e) {

0 comments on commit 4674618

Please sign in to comment.