Github user hdevalke commented on a diff in the pull request: https://github.com/apache/commons-dbutils/pull/3#discussion_r143818665 --- Diff: src/main/java/org/apache/commons/dbutils/BeanProcessor.java --- @@ -65,19 +65,21 @@ */ private static final Map<Class<?>, Object> primitiveDefaults = new HashMap<Class<?>, Object>(); - /** - * ServiceLoader to find <code>ColumnHandler</code> implementations on the classpath. The iterator for this is - * lazy and each time <code>iterator()</code> is called. - */ - // FIXME: I think this instantiates new handlers on each iterator() call. This might be worth caching upfront. - private static final ServiceLoader<ColumnHandler> columnHandlers = ServiceLoader.load(ColumnHandler.class); + private static final List<ColumnHandler> columnHandlers = new ArrayList<ColumnHandler>(); - /** - * ServiceLoader to find <code>PropertyHandler</code> implementations on the classpath. The iterator for this is - * lazy and each time <code>iterator()</code> is called. - */ - // FIXME: I think this instantiates new handlers on each iterator() call. This might be worth caching upfront. - private static final ServiceLoader<PropertyHandler> propertyHandlers = ServiceLoader.load(PropertyHandler.class); + static{ + for (ColumnHandler h : ServiceLoader.load(ColumnHandler.class)) { + columnHandlers.add(h); + } + } + + private static final List<PropertyHandler> propertyHandlers = new ArrayList<PropertyHandler>(); + + static { + for (PropertyHandler h : ServiceLoader.load(PropertyHandler.class)) { + propertyHandlers.add(h); --- End diff -- Can you explain why that is problematic?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org