Commits

tbrugz committed 996cf7a

resultset: BaseResultSetCollectionAdapter: fix for 'null get methods' in beans

Comments (0)

Files changed (1)

src/tbrugz/queryon/resultset/BaseResultSetCollectionAdapter.java

 
 public class BaseResultSetCollectionAdapter<E extends Object> extends AbstractResultSet {
 	
-	static final Log log = LogFactory.getLog(ResultSetCollectionAdapter.class);
+	static final Log log = LogFactory.getLog(BaseResultSetCollectionAdapter.class);
 
 	final String name;
 	final ResultSetMetaData metadata;
 		PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
 		if(uniqueCols!=null) {
 			for(String col: uniqueCols) {
-				addMatchProperties(propertyDescriptors, col, columnNames);
+				addMatchProperties(clazz, propertyDescriptors, col, columnNames);
 			}
 		}
 		if(!onlyUniqueCols) {
 			if(allCols!=null) {
 				for(String col: allCols) {
-					addMatchProperties(propertyDescriptors, col, columnNames);
+					addMatchProperties(clazz, propertyDescriptors, col, columnNames);
 				}
 			}
 			else {
-				addMatchProperties(propertyDescriptors, null, columnNames);
+				addMatchProperties(clazz, propertyDescriptors, null, columnNames);
 			}
 		}
 		log.debug("resultset:cols: "+columnNames);
 	}
 	
-	void addMatchProperties(PropertyDescriptor[] propertyDescriptors, String matchCol, List<String> columnNames) {
+	void addMatchProperties(Class<?> clazz, PropertyDescriptor[] propertyDescriptors, String matchCol, List<String> columnNames) {
 		for (PropertyDescriptor prop : propertyDescriptors) {
 			if(matchCol==null || matchCol.equals(prop.getName())) {
 				String pname = prop.getName();
 				//XXX: continue on transient, ... ??
 				
 				Method m = prop.getReadMethod();
+				if(m==null) {
+					log.warn("null get method? prop: "+pname+" class: "+clazz.getSimpleName());
+					continue;
+				}
 				columnNames.add(pname);
 				methods.add(m);
 			}
 		String ret = null;
 		try {
 			Method m = methods.get(columnIndex-1);
-			if(m==null) { log.warn("method is null: "+(columnIndex-1)); return null; }
+			if(m==null) {
+				log.warn("method is null ["+(columnIndex-1)+"/"+methods.size()+"]");
+				return null;
+			}
 			Object oret = m.invoke(currentElement, (Object[]) null);
 			if(oret==null) { return null; }
 			ret = String.valueOf(oret);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.