Buggy code:
public final class TemplateFactory { private static final Logger log = Logger . getLogger ( TemplateFactory . class . getName ( ) ) ; public static final String KEY_CACHE_RESET = Template . wrap ( "DragonFlyCacheReset" ) ; public static final String KEY_CACHE_LOAD = Template . wrap ( "DragonFlyCacheLoad" ) ; public static final String KEY_FULLNAME = Template . wrap ( "DragonFlyFullName" ) ; private static final String DEFAULT_FULLNAME = "root.default." ; private static final String FULLNAME_QUERY = "SELECT<seq2seq4repair_space>ID_TEMPLATE<seq2seq4repair_space>" + ( ( ( "FROM<seq2seq4repair_space>TEMPLATE<seq2seq4repair_space>" + "WHERE<seq2seq4repair_space>TEMPLATE.COLLECTION<seq2seq4repair_space>=<seq2seq4repair_space>:collection<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>TEMPLATE.NAME<seq2seq4repair_space>=<seq2seq4repair_space>:name" ) + "AND<seq2seq4repair_space>TEMPLATE.COLUMN<seq2seq4repair_space>=<seq2seq4repair_space>:column" ) ; private static final String DEFAULT_QUERY = "SELECT<seq2seq4repair_space>ID_TEMPLATE" + ( ( ( "FROM<seq2seq4repair_space>TEMPLATE<seq2seq4repair_space>" + "WHERE<seq2seq4repair_space>TEMPLATE.COLLECTION<seq2seq4repair_space>=<seq2seq4repair_space>:collection<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>TEMPLATE.NAME<seq2seq4repair_space>=<seq2seq4repair_space>:name" ) + "AND<seq2seq4repair_space>TEMPLATE.COLUMN<seq2seq4repair_space>=<seq2seq4repair_space>''" ) ; private static SessionFactory sessionFactory ; private static ServiceRegistry serviceRegistry ; private static final ConcurrentHashMap < String , Template > templateCache = new ConcurrentHashMap < String , Template > ( ) ; private static String templateFolder = "//tmp//templates" ; private static boolean dbPersistance = false ; public static Template getTemplate ( Map < String , String [ ] > request ) throws MergeException { HashMap < String , String > replace = new HashMap < String , String > ( ) ; replace . put ( TemplateFactory . KEY_FULLNAME , TemplateFactory . DEFAULT_FULLNAME ) ; for ( String key : request . keySet ( ) ) { String value = request . get ( key ) [ 0 ] ; <START_BUG> replace . put ( key , value ) ; <END_BUG> } if ( replace . containsKey ( TemplateFactory . KEY_CACHE_RESET ) ) { TemplateFactory . reset ( ) ; } if ( replace . containsKey ( TemplateFactory . KEY_CACHE_LOAD ) ) { TemplateFactory . loadAll ( ) ; } String fullName = replace . get ( TemplateFactory . KEY_FULLNAME ) ; Template rootTempalte = TemplateFactory . getTemplate ( fullName , "" , replace ) ; return rootTempalte ; } public static Template getTemplate ( String fullName , String shortName , HashMap < String , String > seedReplace ) throws MergeException { } public static String getCollections ( ) throws MergeException { } private static ArrayList < String > getCollectionsFromCache ( ) { } private static ArrayList < String > getCollectionsFromDb ( ) { } public static String getTemplates ( String collection ) throws MergeException { } public static ArrayList < String > getTemplatesFromCache ( String collection ) { } public static ArrayList < String > getTemplatesFromDb ( String collection ) { } public static String getTemplateAsJson ( String fullName ) throws MergeException { } public static String saveTemplateFromJson ( String json ) throws MergeException { } public static void loadAll ( ) throws MergeException { } public static Template cacheFromJson ( String jsonString ) throws MergeException { } public static Template saveTemplateToDatabase ( Template template ) throws MergeException { } public static Template saveTemplateToJsonFolder ( Template template ) throws MergeException { } public static void reset ( ) { } public static void initilizeHibernate ( ) { } public static int size ( ) { } public static boolean isDbPersistance ( ) { } public static void setDbPersistance ( boolean dbPersistance ) { } public static String getTemplateFolder ( ) { } public static void setTemplateFolder ( String templateFolder ) { } No newline ; at end ; of file ; }

Fix:
replace . put ( Template . wrap ( key ) , value ) ;