Buggy code:
public class MongoMetadata extends AbstractMetadata { private static final long serialVersionUID = 1L ; private static final Logger LOGGER = LoggerFactory . getLogger ( MongoMetadata . class ) ; public static final String DEFAULT_METADATA_COLLECTION = "metadata" ; private static final String LITERAL_ID = "_id" ; private static final String LITERAL_ENTITY_NAME = "entityName" ; private static final String LITERAL_VERSION = "version" ; private static final String LITERAL_STATUS = "status" ; private static final String LITERAL_STATUS_VALUE = "status.value" ; private static final String LITERAL_NAME = "name" ; private final transient DBCollection collection ; private final transient BSONParser mdParser ; private final Factory factory ; public MongoMetadata ( DB db , String metadataCollection , Extensions < BSONObject > parserExtensions , TypeResolver typeResolver , Factory factory ) { } public MongoMetadata ( DB db , Extensions < BSONObject > parserExtensions , TypeResolver typeResolver , Factory factory ) { } @ Override public EntityMetadata getEntityMetadata ( String entityName , String version ) { } @ Override public EntityInfo getEntityInfo ( String entityName ) { } @ SuppressWarnings ( "rawtypes" ) @ Override public String [ ] getEntityNames ( MetadataStatus ... statuses ) { } @ Override public VersionInfo [ ] getEntityVersions ( String entityName ) { } @ Override public void createNewMetadata ( EntityMetadata md ) { } @ Override protected boolean checkVersionExists ( String entityName , String version ) { } @ Override public void updateEntityInfo ( EntityInfo ei ) { } @ Override public void createNewSchema ( EntityMetadata md ) { } private static final char [ ] INVALID_COLLECTION_CHARS = new char [ ] { '-' , '<seq2seq4repair_space>' , '.' } ; @ Override protected void checkDataStoreIsValid ( EntityInfo md ) { } @ Override public void setMetadataStatus ( String entityName , String version , MetadataStatus newStatus , String comment ) { } @ Override public void removeEntity ( String entityName ) { } @ Override public Response getDependencies ( String entityName , String version ) { } @ Override public Response getAccess ( String entityName , String version ) { List < String > entityNames = new ArrayList < > ( ) ; Map < String , Map < String , List < String > > > accessMap = new HashMap < > ( ) ; if ( ( null != entityName ) && ( ! ( entityName . isEmpty ( ) ) ) ) { entityNames . add ( entityName ) ; } else { version = null ; entityNames . addAll ( Arrays . asList ( getEntityNames ( ) ) ) ; } <START_BUG> Response response = new Response ( ) ; <END_BUG> response . setStatus ( COMPLETE ) ; for ( String name : entityNames ) { EntityMetadata metadata ; try { metadata = getEntityMetadata ( name , version ) ; } catch ( Exception e ) { response . setStatus ( PARTIAL ) ; ObjectNode obj = new ObjectNode ( JsonNodeFactory . instance ) ; obj . put ( MongoMetadata . LITERAL_NAME , name ) ; if ( null != version ) { obj . put ( "version" , version ) ; } List < Error > errors = new ArrayList < > ( ) ; errors . add ( Error . get ( "ERR_NO_METADATA" , ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>get<seq2seq4repair_space>metadata<seq2seq4repair_space>for<seq2seq4repair_space>given<seq2seq4repair_space>input.<seq2seq4repair_space>Error<seq2seq4repair_space>message:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ) ; DataError error = new DataError ( obj , errors ) ; response . getDataErrors ( ) . add ( error ) ; continue ; } EntityAccess ea = metadata . getAccess ( ) ; Map < FieldAccess , Path > fa = new HashMap < > ( ) ; FieldCursor fc = metadata . getFieldCursor ( ) ; while ( fc . next ( ) ) { FieldTreeNode ftn = fc . getCurrentNode ( ) ; if ( ftn instanceof Field ) { Field f = ( ( Field ) ( ftn ) ) ; if ( ( ( ! ( f . getAccess ( ) . getFind ( ) . isEmpty ( ) ) ) || ( ! ( f . getAccess ( ) . getInsert ( ) . isEmpty ( ) ) ) ) || ( ! ( f . getAccess ( ) . getUpdate ( ) . isEmpty ( ) ) ) ) { fa . put ( f . getAccess ( ) , f . getFullPath ( ) ) ; } } } helperAddRoles ( ea . getDelete ( ) . getRoles ( ) , "delete" , name , accessMap ) ; helperAddRoles ( ea . getFind ( ) . getRoles ( ) , "find" , name , accessMap ) ; helperAddRoles ( ea . getInsert ( ) . getRoles ( ) , "insert" , name , accessMap ) ; helperAddRoles ( ea . getUpdate ( ) . getRoles ( ) , "update" , name , accessMap ) ; for ( Map . Entry < FieldAccess , Path > entry : fa . entrySet ( ) ) { FieldAccess access = entry . getKey ( ) ; String pathString = ( name + "." ) + ( entry . getValue ( ) . toString ( ) ) ; helperAddRoles ( access . getFind ( ) . getRoles ( ) , "find" , pathString , accessMap ) ; helperAddRoles ( access . getInsert ( ) . getRoles ( ) , "insert" , pathString , accessMap ) ; helperAddRoles ( access . getUpdate ( ) . getRoles ( ) , "update" , pathString , accessMap ) ; } } if ( ! ( accessMap . isEmpty ( ) ) ) { ArrayNode root = new ArrayNode ( JsonNodeFactory . instance ) ; response . setEntityData ( root ) ; for ( Map . Entry < String , Map < String , List < String > > > entry : accessMap . entrySet ( ) ) { String role = entry . getKey ( ) ; Map < String , List < String > > opPathMap = entry . getValue ( ) ;

Fix:
Response response = new Response ( JsonNodeFactory . instance ) ;