/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.core;

public class SingletonFactory
  implements XFactory
{
  XFactory delegate_ = null;
  Object   instance_;

  public SingletonFactory(XFactory delegate) {
    delegate_ = delegate;
  }

  public synchronized Object create(X x) {
    if ( delegate_ != null ) {
      instance_ = delegate_.create(x);
      delegate_ = null;
    }

    return instance_;
  }
}

@@ -405,63 +405,99 @@
     
-instance_ = delegate_.create(x);%0A      delegate_ = null
+XFactory delegate = delegate_;%0A      delegate_ = null;%0A      instance_ = delegate.create(x)
 ;%0A  

Fix to avoid duplicate creation in SingletonFactory.