Github user garydgregory commented on a diff in the pull request:

    https://github.com/apache/commons-dbutils/pull/3#discussion_r143822953
  
    --- 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 --
    
    I think of it the other way around: Why use two blocks when you could use 
one?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to