Buggy code:
public class MappingTool implements MetaDataModes { public static final String SCHEMA_ACTION_NONE = "none" ; public static final String ACTION_ADD = "add" ; public static final String ACTION_REFRESH = "refresh" ; public static final String ACTION_BUILD_SCHEMA = "buildSchema" ; public static final String ACTION_DROP = "drop" ; public static final String ACTION_VALIDATE = "validate" ; public static final String ACTION_EXPORT = "export" ; public static final String ACTION_IMPORT = "import" ; public static final String [ ] ACTIONS = new String [ ] { MappingTool . ACTION_ADD , MappingTool . ACTION_REFRESH , MappingTool . ACTION_BUILD_SCHEMA , MappingTool . ACTION_DROP , MappingTool . ACTION_VALIDATE , MappingTool . ACTION_EXPORT , MappingTool . ACTION_IMPORT } ; private static Localizer _loc = Localizer . forPackage ( MappingTool . class ) ; private final JDBCConfiguration _conf ; private final Log _log ; private final String _action ; private final boolean _meta ; private final int _mode ; private MappingRepository _repos = null ; private SchemaGroup _schema = null ; private SchemaTool _schemaTool = null ; private String _schemaActions = SchemaTool . ACTION_ADD ; private boolean _readSchema = false ; private boolean _pks = false ; private boolean _fks = false ; private boolean _indexes = false ; private boolean _seqs = true ; private boolean _dropUnused = true ; private boolean _ignoreErrors = false ; private File _file = null ; private Writer _mappingWriter = null ; private Writer _schemaWriter = null ; private Set _dropCls = null ; private Set _dropMap = null ; private boolean _flush = false ; private boolean _flushSchema = false ; public MappingTool ( JDBCConfiguration conf , String action , boolean meta ) { } public String getAction ( ) { } public boolean isMetaDataAction ( ) { } public String getSchemaAction ( ) { } public void setSchemaAction ( String schemaAction ) { } public boolean getReadSchema ( ) { } public void setReadSchema ( boolean readSchema ) { } public boolean getSequences ( ) { } public void setSequences ( boolean seqs ) { } public boolean getIndexes ( ) { } public void setIndexes ( boolean indexes ) { } public boolean getForeignKeys ( ) { } public void setForeignKeys ( boolean fks ) { } public boolean getPrimaryKeys ( ) { } public void setPrimaryKeys ( boolean pks ) { } public boolean getDropUnusedComponents ( ) { } public void setDropUnusedComponents ( boolean dropUnused ) { } public void setIgnoreErrors ( boolean ignoreErrors ) { } public boolean getIgnoreErrors ( ) { } private SchemaTool newSchemaTool ( String action ) { } public void setSchemaTool ( SchemaTool tool ) { } public Writer getSchemaWriter ( ) { } public void setSchemaWriter ( Writer schemaWriter ) { } public Writer getMappingWriter ( ) { } public void setMappingWriter ( Writer mappingWriter ) { } public File getMetaDataFile ( ) { } public void setMetaDataFile ( File file ) { } public MappingRepository getRepository ( ) { } public void setRepository ( MappingRepository repos ) { } public SchemaGroup getSchemaGroup ( ) { if ( ( _schema ) == null ) { <START_BUG> if ( _action . contains ( MappingTool . ACTION_BUILD_SCHEMA ) ) { <END_BUG> DynamicSchemaFactory factory = new DynamicSchemaFactory ( ) ; factory . setConfiguration ( _conf ) ; _schema = factory ; } else if ( ( ( _readSchema ) || ( _schemaActions . contains ( ACTION_RETAIN ) ) ) || ( _schemaActions . contains ( SchemaTool . ACTION_REFRESH ) ) ) { _schema = ( ( SchemaGroup ) ( newSchemaTool ( null ) . getDBSchemaGroup ( ) . clone ( ) ) ) ; } else { LazySchemaFactory factory = new LazySchemaFactory ( ) ; factory . setConfiguration ( _conf ) ; factory . setPrimaryKeys ( getPrimaryKeys ( ) ) ; factory . setForeignKeys ( getForeignKeys ( ) ) ; factory . setIndexes ( getIndexes ( ) ) ; _schema = factory ; } if ( ( _schema . getSchemas ( ) . length ) == 0 ) _schema . addSchema ( ) ; } return _schema ; } public void setSchemaGroup ( SchemaGroup schema ) { } public void clear ( ) { } public void record ( ) { } private void record ( MappingTool . Flags flags ) { } private void dropUnusedSchemaComponents ( ClassMapping [ ] mappings ) { } private void addSequenceComponents ( ClassMapping [ ] mappings ) { } private void addSequenceComponents ( ClassMapping mapping , SchemaGroup group ) { } public void run ( Class cls ) { } private void add ( Class cls ) { } private static ClassMapping getMapping ( MappingRepository repos , Class cls , boolean validate ) { } private void addMeta ( Class cls ) { } private void refresh ( Class cls ) { } private void validate ( Class cls ) { } private void buildSchema ( Class cls ) { } private void drop ( Class cls ) { } public static void main ( String [ ] args ) throws IOException , SQLException { } public static boolean run ( JDBCConfiguration conf , String [ ] args , Options opts ) throws IOException , SQLException { } public static boolean run ( JDBCConfiguration conf , String [ ] args , MappingTool . Flags flags , ClassLoader loader ) throws IOException , SQLException { } private static MappingTool . ImportExport [ ] newImportExports ( ) { } public static class Flags { public String action = null ; public boolean meta = false ; public String schemaAction = SchemaTool . ACTION_ADD ; public File metaDataFile = null ; public Writer mappingWriter = null ; public Writer schemaWriter = null ; public Writer sqlWriter = null ; public boolean ignoreErrors = false ; public boolean readSchema = false ; public boolean dropTables = false ; public boolean openjpaTables = false ; public boolean dropSequences = false ; public boolean sequences = true ; public boolean primaryKeys = false ; public boolean foreignKeys = false ;

Fix:
if ( ( _action . indexOf ( MappingTool . ACTION_BUILD_SCHEMA ) ) != ( - 1 ) ) {