nus-yam/ex-repair huggingface dataset:
Program: 128579
Project: 128579
Buggy source:
/** 
 * DOC cantoine. Method to return DatabaseMetaData of a DB connection.
 * @param Connection conn
 * @param isSqlMode
 * @param DatabaseConnection dbConn
 * @return DatabaseMetaData
 */
public static DatabaseMetaData getDatabaseMetaData(Connection conn,DatabaseConnection dbConn,boolean isSqlMode){
  DatabaseMetaData dbMetaData=null;
  try {
    String dbType=dbConn.getDatabaseType();
    if ("String_Node_Str".equals(conn.getClass().getName())) {
      dbMetaData=createJtdsDatabaseMetaData(conn);
    }
 else     if (dbType.equals(EDatabaseTypeName.IBMDB2ZOS.getXmlName())) {
      dbMetaData=createFakeDatabaseMetaData(conn);
    }
 else     if (dbType.equals(EDatabaseTypeName.TERADATA.getXmlName()) && isSqlMode) {
      String database=dbConn.getSID();
      dbMetaData=createTeradataFakeDatabaseMetaData(conn);
      TeradataDataBaseMetadata teraDbmeta=(TeradataDataBaseMetadata)dbMetaData;
      teraDbmeta.setDatabaseName(database);
    }
 else     if (dbType.equals(EDatabaseTypeName.SAS.getXmlName())) {
      dbMetaData=createSASFakeDatabaseMetaData(conn);
    }
 else     if (EDatabaseTypeName.SYBASEASE.getDisplayName().equals(dbType)) {
      dbMetaData=createSybaseFakeDatabaseMetaData(conn);
    }
 else {
      dbMetaData=conn.getMetaData();
    }
  }
 catch (  SQLException e) {
    log.error(e.toString());
    throw new RuntimeException(e);
  }
catch (  Exception e) {
    log.error(e.toString());
    throw new RuntimeException(e);
  }
  return dbMetaData;
}

Fixed version (ground truth):
/** 
 * DOC cantoine. Method to return DatabaseMetaData of a DB connection.
 * @param Connection conn
 * @param isSqlMode
 * @param DatabaseConnection dbConn
 * @return DatabaseMetaData
 */
public static DatabaseMetaData getDatabaseMetaData(Connection conn,DatabaseConnection dbConn,boolean isSqlMode){
  DatabaseMetaData dbMetaData=null;
  try {
    String dbType=dbConn.getDatabaseType();
    if ("String_Node_Str".equals(conn.getClass().getName())) {
      dbMetaData=createJtdsDatabaseMetaData(conn);
    }
 else     if (dbType.equals(EDatabaseTypeName.IBMDB2ZOS.getXmlName())) {
      dbMetaData=createFakeDatabaseMetaData(conn);
    }
 else     if (dbType.equals(EDatabaseTypeName.TERADATA.getXmlName()) && isSqlMode) {
      String database=dbConn.getSID();
      dbMetaData=createTeradataFakeDatabaseMetaData(conn);
      TeradataDataBaseMetadata teraDbmeta=(TeradataDataBaseMetadata)dbMetaData;
      teraDbmeta.setDatabaseName(database);
    }
 else     if (dbType.equals(EDatabaseTypeName.SAS.getXmlName())) {
      dbMetaData=createSASFakeDatabaseMetaData(conn);
    }
 else     if (EDatabaseTypeName.SYBASEASE.getDisplayName().equals(dbType) || SYBASE_DATABASE_PRODUCT_NAME.equals(dbType)) {
      dbMetaData=createSybaseFakeDatabaseMetaData(conn);
    }
 else {
      dbMetaData=conn.getMetaData();
    }
  }
 catch (  SQLException e) {
    log.error(e.toString());
    throw new RuntimeException(e);
  }
catch (  Exception e) {
    log.error(e.toString());
    throw new RuntimeException(e);
  }
  return dbMetaData;
}
Program: 128580
Project: 128580
Buggy source:
public static <E>DynaEnum<? extends DynaEnum<?>>[] values(){
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  String projectType=null;
  if (currentProject != null) {
    projectType=currentProject.getEmfProject().getType();
  }
  if ("String_Node_Str".equals(projectType)) {
    List<ERepositoryObjectType> toReturn=new ArrayList<ERepositoryObjectType>();
    for (    ERepositoryObjectType currentType : values(ERepositoryObjectType.class)) {
      if (ArrayUtils.contains(currentType.getProducts(),"String_Node_Str") || ArrayUtils.contains(currentType.getProducts(),"String_Node_Str")) {
        toReturn.add(currentType);
      }
    }
    return toReturn.toArray(new ERepositoryObjectType[]{});
  }
  return values(ERepositoryObjectType.class);
}

Fixed version (ground truth):
public static <E>DynaEnum<? extends DynaEnum<?>>[] values(){
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  String projectType=null;
  if (currentProject != null) {
    projectType=currentProject.getEmfProject().getType();
  }
  if ("String_Node_Str".equals(projectType)) {
    List<ERepositoryObjectType> toReturn=new ArrayList<ERepositoryObjectType>();
    for (    ERepositoryObjectType currentType : values(ERepositoryObjectType.class)) {
      if (ArrayUtils.contains(currentType.getProducts(),"String_Node_Str") || ArrayUtils.contains(currentType.getProducts(),"String_Node_Str")) {
        toReturn.add(currentType);
      }
    }
    return toReturn.toArray(new ERepositoryObjectType[]{});
  }
  if (!PluginChecker.isPluginLoaded("String_Node_Str")) {
    List<ERepositoryObjectType> toReturn=new ArrayList<ERepositoryObjectType>();
    for (    ERepositoryObjectType currentType : values(ERepositoryObjectType.class)) {
      if (!(currentType.getProducts().length == 1 && ArrayUtils.contains(currentType.getProducts(),"String_Node_Str"))) {
        toReturn.add(currentType);
      }
    }
    return toReturn.toArray(new ERepositoryObjectType[0]);
  }
  return values(ERepositoryObjectType.class);
}
Program: 128581
Project: 128581
Buggy source:
public Resource createTempProjectResource(){
  URI uri=null;
  try {
    uri=URI.createPlatformResourceURI(Platform.getInstallLocation().getURL().toURI().toString());
  }
 catch (  URISyntaxException e) {
    ExceptionHandler.process(e);
  }
  return resourceSet.createResource(uri);
}

Fixed version (ground truth):
public Resource createTempProjectResource(){
  URI uri=null;
  try {
    uri=URI.createPlatformResourceURI(Platform.getInstallLocation().getURL().getFile(),true);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  return resourceSet.createResource(uri);
}
Program: 128583
Project: 128583
Buggy source:
public Object caseJobletDocumentationItem(JobletDocumentationItem object){
  return JOBLET_DOC;
}

Fixed version (ground truth):
@Override public Object caseJobletDocumentationItem(JobletDocumentationItem object){
  return JOBLET_DOC;
}
Program: 128584
Project: 128584
Buggy source:
public Object caseLdifFileConnectionItem(LdifFileConnectionItem object){
  return METADATA_FILE_LDIF;
}

Fixed version (ground truth):
@Override public Object caseLdifFileConnectionItem(LdifFileConnectionItem object){
  return METADATA_FILE_LDIF;
}
Program: 128585
Project: 128585
Buggy source:
public Object caseContextItem(ContextItem object){
  return CONTEXT;
}

Fixed version (ground truth):
@Override public Object caseContextItem(ContextItem object){
  return CONTEXT;
}
Program: 128586
Project: 128586
Buggy source:
public Object caseDocumentationItem(DocumentationItem object){
  return DOCUMENTATION;
}

Fixed version (ground truth):
@Override public Object caseDocumentationItem(DocumentationItem object){
  return DOCUMENTATION;
}
Program: 128587
Project: 128587
Buggy source:
public Object caseHeaderFooterConnectionItem(HeaderFooterConnectionItem object){
  return METADATA_HEADER_FOOTER;
}

Fixed version (ground truth):
@Override public Object caseHeaderFooterConnectionItem(HeaderFooterConnectionItem object){
  return METADATA_HEADER_FOOTER;
}
Program: 128589
Project: 128589
Buggy source:
public Object caseXmlFileConnectionItem(XmlFileConnectionItem object){
  return METADATA_FILE_XML;
}

Fixed version (ground truth):
@Override public Object caseXmlFileConnectionItem(XmlFileConnectionItem object){
  return METADATA_FILE_XML;
}
Program: 128590
Project: 128590
Buggy source:
public Object caseProcessItem(ProcessItem object){
  return PROCESS;
}

Fixed version (ground truth):
@Override public Object caseProcessItem(ProcessItem object){
  return PROCESS;
}
Program: 128591
Project: 128591
Buggy source:
public Object caseFTPConnectionItem(FTPConnectionItem object){
  return METADATA_FILE_FTP;
}

Fixed version (ground truth):
@Override public Object caseFTPConnectionItem(FTPConnectionItem object){
  return METADATA_FILE_FTP;
}
Program: 128592
Project: 128592
Buggy source:
public Object caseCSVFileConnectionItem(CSVFileConnectionItem object){
  throw new IllegalStateException(Messages.getString("String_Node_Str"));
}

Fixed version (ground truth):
@Override public Object caseCSVFileConnectionItem(CSVFileConnectionItem object){
  throw new IllegalStateException(Messages.getString("String_Node_Str"));
}
Program: 128593
Project: 128593
Buggy source:
public Object caseEDIFACTConnectionItem(EDIFACTConnectionItem object){
  return METADATA_EDIFACT;
}

Fixed version (ground truth):
@Override public Object caseEDIFACTConnectionItem(EDIFACTConnectionItem object){
  return METADATA_EDIFACT;
}
Program: 128594
Project: 128594
Buggy source:
public Object caseRoutineItem(RoutineItem object){
  return ROUTINES;
}

Fixed version (ground truth):
@Override public Object caseRoutineItem(RoutineItem object){
  return ROUTINES;
}
Program: 128595
Project: 128595
Buggy source:
public Object caseValidationRulesConnectionItem(ValidationRulesConnectionItem object){
  return METADATA_VALIDATION_RULES;
}

Fixed version (ground truth):
@Override public Object caseValidationRulesConnectionItem(ValidationRulesConnectionItem object){
  return METADATA_VALIDATION_RULES;
}
Program: 128596
Project: 128596
Buggy source:
public Object caseHL7ConnectionItem(HL7ConnectionItem object){
  return METADATA_FILE_HL7;
}

Fixed version (ground truth):
@Override public Object caseHL7ConnectionItem(HL7ConnectionItem object){
  return METADATA_FILE_HL7;
}
Program: 128597
Project: 128597
Buggy source:
public Object caseSnippetItem(SnippetItem object){
  return SNIPPETS;
}

Fixed version (ground truth):
@Override public Object caseSnippetItem(SnippetItem object){
  return SNIPPETS;
}
Program: 128598
Project: 128598
Buggy source:
public String name(){
  if (isStaticNode()) {
    Field[] allFields=ERepositoryObjectType.class.getDeclaredFields();
    for (    Field f : allFields) {
      try {
        Object object=f.get(null);
        if (object == this) {
          return f.getName();
        }
      }
 catch (      IllegalArgumentException e) {
      }
catch (      IllegalAccessException e) {
      }
    }
  }
  return super.name();
}

Fixed version (ground truth):
@Override public String name(){
  if (isStaticNode()) {
    Field[] allFields=ERepositoryObjectType.class.getDeclaredFields();
    for (    Field f : allFields) {
      try {
        Object object=f.get(null);
        if (object == this) {
          return f.getName();
        }
      }
 catch (      IllegalArgumentException e) {
      }
catch (      IllegalAccessException e) {
      }
    }
  }
  return super.name();
}
Program: 128599
Project: 128599
Buggy source:
public Object caseSnippetVariable(SnippetVariable object){
  return SNIPPETS;
}

Fixed version (ground truth):
@Override public Object caseSnippetVariable(SnippetVariable object){
  return SNIPPETS;
}
Program: 128600
Project: 128600
Buggy source:
public Object casePositionalFileConnectionItem(PositionalFileConnectionItem object){
  return METADATA_FILE_POSITIONAL;
}

Fixed version (ground truth):
@Override public Object casePositionalFileConnectionItem(PositionalFileConnectionItem object){
  return METADATA_FILE_POSITIONAL;
}
Program: 128601
Project: 128601
Buggy source:
public static <E>DynaEnum<? extends DynaEnum<?>>[] values(){
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  String projectType=null;
  if (currentProject != null) {
    projectType=currentProject.getEmfProject().getType();
  }
  if ("String_Node_Str".equals(projectType)) {
    List<ERepositoryObjectType> toReturn=new ArrayList<ERepositoryObjectType>();
    for (    ERepositoryObjectType currentType : values(ERepositoryObjectType.class)) {
      if (ArrayUtils.contains(currentType.getProducts(),"String_Node_Str") || ArrayUtils.contains(currentType.getProducts(),"String_Node_Str")) {
        toReturn.add(currentType);
      }
    }
    return toReturn.toArray(new ERepositoryObjectType[]{});
  }
  return values(ERepositoryObjectType.class);
}

Fixed version (ground truth):
public static <E>DynaEnum<? extends DynaEnum<?>>[] values(){
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  String projectType=null;
  if (currentProject != null) {
    projectType=currentProject.getEmfProject().getType();
  }
  if ("String_Node_Str".equals(projectType)) {
    List<ERepositoryObjectType> toReturn=new ArrayList<ERepositoryObjectType>();
    for (    ERepositoryObjectType currentType : values(ERepositoryObjectType.class)) {
      if (ArrayUtils.contains(currentType.getProducts(),"String_Node_Str") || ArrayUtils.contains(currentType.getProducts(),"String_Node_Str")) {
        toReturn.add(currentType);
      }
    }
    return toReturn.toArray(new ERepositoryObjectType[]{});
  }
  if (!PluginChecker.isPluginLoaded("String_Node_Str")) {
    List<ERepositoryObjectType> toReturn=new ArrayList<ERepositoryObjectType>();
    for (    ERepositoryObjectType currentType : values(ERepositoryObjectType.class)) {
      if (!(currentType.getProducts().length == 1 && ArrayUtils.contains(currentType.getProducts(),"String_Node_Str"))) {
        toReturn.add(currentType);
      }
    }
    return toReturn.toArray(new ERepositoryObjectType[0]);
  }
  return values(ERepositoryObjectType.class);
}
Program: 128602
Project: 128602
Buggy source:
public Object caseMDMConnectionItem(MDMConnectionItem object){
  return METADATA_MDMCONNECTION;
}

Fixed version (ground truth):
@Override public Object caseMDMConnectionItem(MDMConnectionItem object){
  return METADATA_MDMCONNECTION;
}
Program: 128603
Project: 128603
Buggy source:
public Object caseJobScriptItem(JobScriptItem object){
  return JOB_SCRIPT;
}

Fixed version (ground truth):
@Override public Object caseJobScriptItem(JobScriptItem object){
  return JOB_SCRIPT;
}
Program: 128604
Project: 128604
Buggy source:
public Object caseJobDocumentationItem(JobDocumentationItem object){
  return JOB_DOC;
}

Fixed version (ground truth):
@Override public Object caseJobDocumentationItem(JobDocumentationItem object){
  return JOB_DOC;
}
Program: 128605
Project: 128605
Buggy source:
public Object caseDelimitedFileConnectionItem(DelimitedFileConnectionItem object){
  return METADATA_FILE_DELIMITED;
}

Fixed version (ground truth):
@Override public Object caseDelimitedFileConnectionItem(DelimitedFileConnectionItem object){
  return METADATA_FILE_DELIMITED;
}
Program: 128606
Project: 128606
Buggy source:
public Object caseSalesforceSchemaConnectionItem(SalesforceSchemaConnectionItem object){
  return METADATA_SALESFORCE_SCHEMA;
}

Fixed version (ground truth):
@Override public Object caseSalesforceSchemaConnectionItem(SalesforceSchemaConnectionItem object){
  return METADATA_SALESFORCE_SCHEMA;
}
Program: 128607
Project: 128607
Buggy source:
public Object caseExcelFileConnectionItem(ExcelFileConnectionItem object){
  return METADATA_FILE_EXCEL;
}

Fixed version (ground truth):
@Override public Object caseExcelFileConnectionItem(ExcelFileConnectionItem object){
  return METADATA_FILE_EXCEL;
}
Program: 128608
Project: 128608
Buggy source:
public Object caseWSDLSchemaConnectionItem(WSDLSchemaConnectionItem object){
  return METADATA_WSDL_SCHEMA;
}

Fixed version (ground truth):
@Override public Object caseWSDLSchemaConnectionItem(WSDLSchemaConnectionItem object){
  return METADATA_WSDL_SCHEMA;
}
Program: 128610
Project: 128610
Buggy source:
public Object caseGenericSchemaConnectionItem(GenericSchemaConnectionItem object){
  return METADATA_GENERIC_SCHEMA;
}

Fixed version (ground truth):
@Override public Object caseGenericSchemaConnectionItem(GenericSchemaConnectionItem object){
  return METADATA_GENERIC_SCHEMA;
}
Program: 128611
Project: 128611
Buggy source:
public Object caseLDAPSchemaConnectionItem(LDAPSchemaConnectionItem object){
  return METADATA_LDAP_SCHEMA;
}

Fixed version (ground truth):
@Override public Object caseLDAPSchemaConnectionItem(LDAPSchemaConnectionItem object){
  return METADATA_LDAP_SCHEMA;
}
Program: 128612
Project: 128612
Buggy source:
public Object caseRegExFileConnectionItem(RegExFileConnectionItem object){
  return METADATA_FILE_REGEXP;
}

Fixed version (ground truth):
@Override public Object caseRegExFileConnectionItem(RegExFileConnectionItem object){
  return METADATA_FILE_REGEXP;
}
Program: 128613
Project: 128613
Buggy source:
public Object caseBusinessProcessItem(BusinessProcessItem object){
  return BUSINESS_PROCESS;
}

Fixed version (ground truth):
@Override public Object caseBusinessProcessItem(BusinessProcessItem object){
  return BUSINESS_PROCESS;
}
Program: 128614
Project: 128614
Buggy source:
public Object caseDatabaseConnectionItem(DatabaseConnectionItem object){
  return METADATA_CONNECTIONS;
}

Fixed version (ground truth):
@Override public Object caseDatabaseConnectionItem(DatabaseConnectionItem object){
  return METADATA_CONNECTIONS;
}
Program: 128615
Project: 128615
Buggy source:
public Object defaultCase(EObject object){
  throw new IllegalStateException();
}

Fixed version (ground truth):
@Override public Object defaultCase(EObject object){
  throw new IllegalStateException();
}
Program: 128619
Project: 128619
Buggy source:
public Resource createTempProjectResource(){
  URI uri=null;
  try {
    uri=URI.createPlatformResourceURI(Platform.getInstallLocation().getURL().toURI().toString());
  }
 catch (  URISyntaxException e) {
    ExceptionHandler.process(e);
  }
  return resourceSet.createResource(uri);
}

Fixed version (ground truth):
public Resource createTempProjectResource(){
  URI uri=null;
  try {
    uri=URI.createPlatformResourceURI(Platform.getInstallLocation().getURL().getFile(),true);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  return resourceSet.createResource(uri);
}
Program: 128620
Project: 128620
Buggy source:
protected void makeActions(){
  boolean isNewDoubleClickAction=false;
  if (doubleClickAction != null) {
    StructuredViewer structuredViewer=doubleClickAction.getStructuredViewer();
    ISelection selection=structuredViewer.getSelection();
    if (selection.isEmpty()) {
      isNewDoubleClickAction=true;
    }
  }
  if (contextualsActions == null || isNewDoubleClickAction) {
    ICommonViewerWorkbenchSite navWorkSite=((ICommonViewerWorkbenchSite)getActionSite().getViewSite());
    IHandlerService handlerService=(IHandlerService)navWorkSite.getSite().getService(IHandlerService.class);
    IHandler handler=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
      final ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
      if (coreService != null) {
        contextualsActions=coreService.getRepositoryContextualsActions();
        for (        ITreeContextualAction action : contextualsActions) {
          action.setWorkbenchPart(navWorkSite.getSite().getPart());
          if (action.getActionDefinitionId() != null) {
            handler=new ActionHandler(action);
            handlerService.activateHandler(action.getActionDefinitionId(),handler);
          }
        }
      }
    }
    doubleClickAction=new RepoDoubleClickAction(getActionSite().getStructuredViewer(),contextualsActions);
  }
}

Fixed version (ground truth):
protected void makeActions(){
  boolean isNewDoubleClickAction=false;
  if (doubleClickAction != null && doubleClickAction.getStructuredViewer() != null) {
    StructuredViewer structuredViewer=doubleClickAction.getStructuredViewer();
    ISelection selection=structuredViewer.getSelection();
    if (selection == null || selection.isEmpty()) {
      isNewDoubleClickAction=true;
    }
  }
  if (contextualsActions == null || isNewDoubleClickAction) {
    ICommonViewerWorkbenchSite navWorkSite=((ICommonViewerWorkbenchSite)getActionSite().getViewSite());
    IHandlerService handlerService=(IHandlerService)navWorkSite.getSite().getService(IHandlerService.class);
    IHandler handler=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
      final ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
      if (coreService != null) {
        contextualsActions=coreService.getRepositoryContextualsActions();
        for (        ITreeContextualAction action : contextualsActions) {
          action.setWorkbenchPart(navWorkSite.getSite().getPart());
          if (action.getActionDefinitionId() != null) {
            handler=new ActionHandler(action);
            handlerService.activateHandler(action.getActionDefinitionId(),handler);
          }
        }
      }
    }
    doubleClickAction=new RepoDoubleClickAction(getActionSite().getStructuredViewer(),contextualsActions);
  }
}
Program: 128621
Project: 128621
Buggy source:
/** 
 * Constructor to use by a Wizard to create a new database connection.
 * @param existingNames
 * @param Composite
 * @param Wizard
 * @param ISelection
 */
public DatabaseForm(Composite parent,ConnectionItem connectionItem,String[] existingNames,boolean isCreation){
  super(parent,SWT.NONE,existingNames);
  this.connectionItem=connectionItem;
  this.isCreation=isCreation;
  setConnectionItem(connectionItem);
  this.metadataconnection=ConvertionHelper.convert(getConnection());
  this.typeName=EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType());
  if (typeName != null && typeName.isUseProvider()) {
    this.provider=ExtractMetaDataFromDataBase.getProviderByDbType(metadataconnection.getDbType());
  }
  setupForm(true);
  addStringConnectionControls();
  GridLayout layout2=(GridLayout)getLayout();
  layout2.marginHeight=0;
  setLayout(layout2);
}

Fixed version (ground truth):
/** 
 * Constructor to use by a Wizard to create a new database connection.
 * @param existingNames
 * @param Composite
 * @param Wizard
 * @param ISelection
 */
public DatabaseForm(Composite parent,ConnectionItem connectionItem,String[] existingNames,boolean isCreation){
  super(parent,SWT.NONE,existingNames);
  this.connectionItem=connectionItem;
  this.isCreation=isCreation;
  setConnectionItem(connectionItem);
  this.metadataconnection=ConvertionHelper.convert(getConnection(),true);
  this.typeName=EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType());
  if (typeName != null && typeName.isUseProvider()) {
    this.provider=ExtractMetaDataFromDataBase.getProviderByDbType(metadataconnection.getDbType());
  }
  setupForm(true);
  addStringConnectionControls();
  GridLayout layout2=(GridLayout)getLayout();
  layout2.marginHeight=0;
  setLayout(layout2);
}
Program: 128622
Project: 128622
Buggy source:
public boolean getMergeRefProject(){
  IPreferenceStore preferenceStore=RepositoryManager.getPreferenceStore();
  return preferenceStore.getBoolean(IRepositoryPrefConstants.MERGE_REFERENCE_PROJECT);
}

Fixed version (ground truth):
public boolean getMergeRefProject(){
  IPreferenceStore preferenceStore=RepositoryManager.getRepositoryPreferenceStore();
  return preferenceStore.getBoolean(IRepositoryPrefConstants.MERGE_REFERENCE_PROJECT);
}
Program: 128623
Project: 128623
Buggy source:
/** 
 * DOC sgandon Comment method "registerMergeRefListgener".
 */
private void registerMergeRefListener(){
  if (mergeRefListener == null) {
    mergeRefListener=new IPropertyChangeListener(){
      @Override public void propertyChange(      PropertyChangeEvent event){
        if (IRepositoryPrefConstants.MERGE_REFERENCE_PROJECT.equals(event.getProperty())) {
          refreshTopLevelNodes();
        }
      }
    }
;
    if (CoreRuntimePlugin.getInstance().getDesignerCoreService() != null) {
      IPreferenceStore preferenceStore=RepositoryManager.getPreferenceStore();
      preferenceStore.addPropertyChangeListener(mergeRefListener);
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC sgandon Comment method "registerMergeRefListgener".
 */
private void registerMergeRefListener(){
  if (mergeRefListener == null) {
    mergeRefListener=new IPropertyChangeListener(){
      @Override public void propertyChange(      PropertyChangeEvent event){
        if (IRepositoryPrefConstants.MERGE_REFERENCE_PROJECT.equals(event.getProperty())) {
          refreshTopLevelNodes();
        }
      }
    }
;
    if (CoreRuntimePlugin.getInstance().getDesignerCoreService() != null) {
      IPreferenceStore preferenceStore=RepositoryManager.getRepositoryPreferenceStore();
      preferenceStore.addPropertyChangeListener(mergeRefListener);
    }
  }
}
Program: 128625
Project: 128625
Buggy source:
public static List parseTo_List(String s){
  if (s != null) {
    List list=new ArrayList();
    list.add(s);
    return list;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * the source should be a string wrapped in chars[ ] which stands for it is a collection
 * @param stSrc
 * @param fieldSep
 * @return
 */
public static List<String> parseTo_List(String strSrc,String fieldSep){
  if (strSrc == null) {
    return null;
  }
  List<String> list=new ArrayList<String>();
  if ((fieldSep == null || "String_Node_Str".equals(fieldSep)) || !(strSrc.startsWith("String_Node_Str") && strSrc.endsWith("String_Node_Str"))) {
    list.add(strSrc);
    return list;
  }
  return Arrays.asList(strSrc.split(fieldSep,-1));
}
Program: 128626
Project: 128626
Buggy source:
@Override public void selectionChanged(IStructuredSelection selection){
  FOXTreeNode node=(FOXTreeNode)this.getStructuredSelection().getFirstElement();
  if (node == null) {
    this.setEnabled(false);
  }
 else {
    if (node.getParent() == null) {
      this.setEnabled(false);
    }
 else     if (node.getColumn() != null) {
      this.setEnabled(false);
    }
 else     if (node.getChildren() != null && !node.getChildren().isEmpty()) {
      this.setEnabled(false);
    }
 else {
      this.setEnabled(true);
    }
  }
}

Fixed version (ground truth):
@Override public void selectionChanged(IStructuredSelection selection){
  FOXTreeNode node=(FOXTreeNode)this.getStructuredSelection().getFirstElement();
  if (node == null) {
    this.setEnabled(false);
  }
 else {
    if (node.getParent() == null) {
      this.setEnabled(false);
    }
 else     if (node.getColumn() != null) {
      this.setEnabled(false);
    }
 else     if (node.getChildren() != null && !node.getChildren().isEmpty()) {
      boolean haveElementChild=false;
      for (      FOXTreeNode child : node.getChildren()) {
        if (child instanceof Element) {
          haveElementChild=true;
          break;
        }
      }
      if (haveElementChild) {
        setEnabled(false);
      }
 else {
        setEnabled(true);
      }
    }
 else {
      this.setEnabled(true);
    }
  }
}
Program: 128627
Project: 128627
Buggy source:
public void run(){
  FOXTreeNode node=(FOXTreeNode)this.getStructuredSelection().getFirstElement();
  if (node != null) {
    setFixValue(node);
  }
}

Fixed version (ground truth):
@Override public void run(){
  FOXTreeNode node=(FOXTreeNode)this.getStructuredSelection().getFirstElement();
  if (node != null) {
    setFixValue(node);
  }
}
Program: 128629
Project: 128629
Buggy source:
public void dragEnter(DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dragEnter(DropTargetEvent event){
}
Program: 128630
Project: 128630
Buggy source:
public void dropAccept(DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dropAccept(DropTargetEvent event){
}
Program: 128631
Project: 128631
Buggy source:
public void dragStart(DragSourceEvent event){
  TableItem[] items=linker.getSource().getSelection();
  if (items.length == 0) {
    event.doit=false;
  }
 else {
    LocalDraggedData draggedData=new LocalDraggedData();
    for (    TableItem tableItem : items) {
      draggedData.add(tableItem.getData());
    }
    draggedData.setTable(getMainForm().getMetadataTable());
    LocalDataTransfer.getInstance().setLocalDraggedData(draggedData);
  }
}

Fixed version (ground truth):
@Override public void dragStart(DragSourceEvent event){
  TableItem[] items=linker.getSource().getSelection();
  if (items.length == 0) {
    event.doit=false;
  }
 else {
    LocalDraggedData draggedData=new LocalDraggedData();
    for (    TableItem tableItem : items) {
      draggedData.add(tableItem.getData());
    }
    draggedData.setTable(getMainForm().getMetadataTable());
    LocalDataTransfer.getInstance().setLocalDraggedData(draggedData);
  }
}
Program: 128632
Project: 128632
Buggy source:
public void dragSetData(DragSourceEvent event){
  event.getSource();
}

Fixed version (ground truth):
@Override public void dragSetData(DragSourceEvent event){
  event.getSource();
}
Program: 128633
Project: 128633
Buggy source:
public void dragFinished(DragSourceEvent event){
  event.getSource();
}

Fixed version (ground truth):
@Override public void dragFinished(DragSourceEvent event){
  event.getSource();
}
Program: 128634
Project: 128634
Buggy source:
public void dragOperationChanged(DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dragOperationChanged(DropTargetEvent event){
}
Program: 128635
Project: 128635
Buggy source:
public Transfer getTransfer(){
  return LocalDataTransfer.getInstance();
}

Fixed version (ground truth):
@Override public Transfer getTransfer(){
  return LocalDataTransfer.getInstance();
}
Program: 128636
Project: 128636
Buggy source:
public boolean isEnabled(DropTargetEvent event){
  return true;
}

Fixed version (ground truth):
@Override public boolean isEnabled(DropTargetEvent event){
  return true;
}
Program: 128637
Project: 128637
Buggy source:
public void dragOver(DropTargetEvent event){
  Item targetItem=(Item)event.item;
  if (targetItem == null) {
    event.detail=DND.DROP_NONE;
    return;
  }
  FOXTreeNode targetNode=(FOXTreeNode)(targetItem.getData());
  LocalDraggedData draggedData=LocalDataTransfer.getInstance().getDraggedData();
  List<Object> dragdedData=draggedData.getTransferableEntryList();
  if (dragdedData.size() == 1 && isDropRelatedColumn(event)) {
    if (targetNode instanceof Element) {
      Element element=(Element)targetNode;
      if (!element.getElementChildren().isEmpty() || element.getParent() == null) {
        event.detail=DND.DROP_NONE;
        return;
      }
    }
 else {
      FOXTreeNode parent=targetNode.getParent();
      if (parent == null) {
        event.detail=DND.DROP_NONE;
        return;
      }
    }
  }
  event.detail=DND.DROP_LINK;
}

Fixed version (ground truth):
@Override public void dragOver(DropTargetEvent event){
  Item targetItem=(Item)event.item;
  if (targetItem == null) {
    event.detail=DND.DROP_NONE;
    return;
  }
  FOXTreeNode targetNode=(FOXTreeNode)(targetItem.getData());
  LocalDraggedData draggedData=LocalDataTransfer.getInstance().getDraggedData();
  List<Object> dragdedData=draggedData.getTransferableEntryList();
  if (dragdedData.size() == 1 && isDropRelatedColumn(event)) {
    if (targetNode instanceof Element) {
      Element element=(Element)targetNode;
      if (!element.getElementChildren().isEmpty() || element.getParent() == null) {
        event.detail=DND.DROP_NONE;
        return;
      }
    }
 else {
      FOXTreeNode parent=targetNode.getParent();
      if (parent == null) {
        event.detail=DND.DROP_NONE;
        return;
      }
    }
  }
  event.detail=DND.DROP_LINK;
}
Program: 128638
Project: 128638
Buggy source:
public void dragLeave(DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dragLeave(DropTargetEvent event){
}
Program: 128640
Project: 128640
Buggy source:
public void run(){
  IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
  list.addAll(Arrays.asList(reference));
}

Fixed version (ground truth):
@Override public void run(){
  IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
  list.addAll(Arrays.asList(reference));
}
Program: 128641
Project: 128641
Buggy source:
public static IEditorReference[] getEditors(){
  final List<IEditorReference> list=new ArrayList<IEditorReference>();
  Display.getDefault().syncExec(new Runnable(){
    public void run(){
      IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
      list.addAll(Arrays.asList(reference));
    }
  }
);
  return list.toArray(new IEditorReference[0]);
}

Fixed version (ground truth):
public static IEditorReference[] getEditors(){
  final List<IEditorReference> list=new ArrayList<IEditorReference>();
  Display.getDefault().syncExec(new Runnable(){
    @Override public void run(){
      IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
      list.addAll(Arrays.asList(reference));
    }
  }
);
  return list.toArray(new IEditorReference[0]);
}
Program: 128644
Project: 128644
Buggy source:
private static boolean updateSchema(final Object table,ConnectionItem connItem,Map<String,String> schemaRenamedMap,boolean show,boolean onlySimpleShow){
  IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
  List<IRepositoryViewObject> updateList=new ArrayList<IRepositoryViewObject>();
  List<RelationshipItemBuilder.Relation> relations=RelationshipItemBuilder.getInstance().getItemsRelatedTo(((ConnectionItem)connItem).getProperty().getId(),RelationshipItemBuilder.LATEST_VERSION,RelationshipItemBuilder.PROPERTY_RELATION);
  RepositoryUpdateManager repositoryUpdateManager=new RepositoryUpdateManager(table,relations){
    @Override public Set<EUpdateItemType> getTypes(){
      Set<EUpdateItemType> types=new HashSet<EUpdateItemType>();
      types.add(EUpdateItemType.NODE_SCHEMA);
      return types;
    }
  }
;
  repositoryUpdateManager.setSchemaRenamedMap(schemaRenamedMap);
  return repositoryUpdateManager.doWork(show,onlySimpleShow);
}

Fixed version (ground truth):
private static boolean updateSchema(final Object table,ConnectionItem connItem,Map<String,String> schemaRenamedMap,boolean show,boolean onlySimpleShow){
  IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
  List<IRepositoryViewObject> updateList=new ArrayList<IRepositoryViewObject>();
  List<RelationshipItemBuilder.Relation> relations=RelationshipItemBuilder.getInstance().getItemsRelatedTo((connItem).getProperty().getId(),RelationshipItemBuilder.LATEST_VERSION,RelationshipItemBuilder.PROPERTY_RELATION);
  RepositoryUpdateManager repositoryUpdateManager=new RepositoryUpdateManager(table,relations){
    @Override public Set<EUpdateItemType> getTypes(){
      Set<EUpdateItemType> types=new HashSet<EUpdateItemType>();
      types.add(EUpdateItemType.NODE_SCHEMA);
      return types;
    }
  }
;
  repositoryUpdateManager.setSchemaRenamedMap(schemaRenamedMap);
  return repositoryUpdateManager.doWork(show,onlySimpleShow);
}
Program: 128647
Project: 128647
Buggy source:
/** 
 * MOD qiongli 2011-11-28 change this method 'private' into 'public'.it is used to judge if need to update DQ analyses.
 */
public static boolean sameAsMetadatTable(List<IMetadataTable> newTables,List<IMetadataTable> oldTables,Map<String,String> oldTableMap){
  if (newTables == null || oldTables == null) {
    return false;
  }
  Map<String,IMetadataTable> id2TableMap=new HashMap<String,IMetadataTable>();
  for (  IMetadataTable oldTable : oldTables) {
    id2TableMap.put(oldTable.getId(),oldTable);
  }
  for (  IMetadataTable newTable : newTables) {
    IMetadataTable oldTable=id2TableMap.get(newTable.getId());
    if (oldTableMap.containsKey(newTable.getId())) {
      if (oldTable == null) {
        return false;
      }
 else {
        if (!newTable.sameMetadataAs(oldTable,IMetadataColumn.OPTIONS_NONE)) {
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
public static boolean sameAsMetadatTable(List<IMetadataTable> newTables,List<IMetadataTable> oldTables,Map<String,String> oldTableMap,int options){
  if (newTables == null || oldTables == null) {
    return false;
  }
  Map<String,IMetadataTable> id2TableMap=new HashMap<String,IMetadataTable>();
  for (  IMetadataTable oldTable : oldTables) {
    id2TableMap.put(oldTable.getId(),oldTable);
  }
  for (  IMetadataTable newTable : newTables) {
    IMetadataTable oldTable=id2TableMap.get(newTable.getId());
    if (oldTableMap.containsKey(newTable.getId())) {
      if (oldTable == null) {
        return false;
      }
 else {
        if (!newTable.sameMetadataAs(oldTable,options)) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 128648
Project: 128648
Buggy source:
@SuppressWarnings("String_Node_Str") private boolean filterForType(UpdateResult result){
  if (result == null || parameter == null) {
    return false;
  }
  Object object=result.getParameter();
  if (object == null) {
    return false;
  }
  if (object == parameter) {
    return true;
  }
  if (object instanceof List) {
    List list=((List)object);
    if (!list.isEmpty()) {
      Object firstObj=list.get(0);
      if (parameter == firstObj) {
        return true;
      }
      if (checkResultSchema(result,firstObj,parameter)) {
        return true;
      }
    }
  }
  if (checkResultSchema(result,object,parameter)) {
    return true;
  }
  if (parameter instanceof QueriesConnection && object instanceof Query) {
    for (    Query query : (List<Query>)((QueriesConnection)parameter).getQuery()) {
      if (query.getId().equals(((Query)object).getId())) {
        return true;
      }
    }
  }
  if ((object instanceof Query) && (parameter instanceof Query)) {
    if (((Query)object).getId().equals(((Query)parameter).getId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private boolean filterForType(UpdateResult result){
  if (result == null || parameter == null) {
    return false;
  }
  Object object=result.getParameter();
  if (object == null) {
    return false;
  }
  if (object == parameter) {
    return true;
  }
  if (object instanceof List) {
    List list=((List)object);
    if (!list.isEmpty()) {
      Object firstObj=list.get(0);
      if (parameter == firstObj) {
        return true;
      }
      if (checkResultSchema(result,firstObj,parameter)) {
        return true;
      }
    }
  }
  if (checkResultSchema(result,object,parameter)) {
    return true;
  }
  if (parameter instanceof QueriesConnection && object instanceof Query) {
    for (    Query query : ((QueriesConnection)parameter).getQuery()) {
      if (query.getId().equals(((Query)object).getId())) {
        return true;
      }
    }
  }
  if ((object instanceof Query) && (parameter instanceof Query)) {
    if (((Query)object).getId().equals(((Query)parameter).getId())) {
      return true;
    }
  }
  return false;
}
Program: 128649
Project: 128649
Buggy source:
protected void makeActions(){
  boolean isNewDoubleClickAction=false;
  if (doubleClickAction != null) {
    StructuredViewer structuredViewer=doubleClickAction.getStructuredViewer();
    ISelection selection=structuredViewer.getSelection();
    if (selection.isEmpty()) {
      isNewDoubleClickAction=true;
    }
  }
  if (contextualsActions == null || isNewDoubleClickAction) {
    ICommonViewerWorkbenchSite navWorkSite=((ICommonViewerWorkbenchSite)getActionSite().getViewSite());
    IHandlerService handlerService=(IHandlerService)navWorkSite.getSite().getService(IHandlerService.class);
    IHandler handler=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
      final ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
      if (coreService != null) {
        contextualsActions=coreService.getRepositoryContextualsActions();
        for (        ITreeContextualAction action : contextualsActions) {
          action.setWorkbenchPart(navWorkSite.getSite().getPart());
          if (action.getActionDefinitionId() != null) {
            handler=new ActionHandler(action);
            handlerService.activateHandler(action.getActionDefinitionId(),handler);
          }
        }
      }
    }
    doubleClickAction=new RepoDoubleClickAction(getActionSite().getStructuredViewer(),contextualsActions);
  }
}

Fixed version (ground truth):
protected void makeActions(){
  boolean isNewDoubleClickAction=false;
  if (doubleClickAction != null && doubleClickAction.getStructuredViewer() != null) {
    StructuredViewer structuredViewer=doubleClickAction.getStructuredViewer();
    ISelection selection=structuredViewer.getSelection();
    if (selection == null || selection.isEmpty()) {
      isNewDoubleClickAction=true;
    }
  }
  if (contextualsActions == null || isNewDoubleClickAction) {
    ICommonViewerWorkbenchSite navWorkSite=((ICommonViewerWorkbenchSite)getActionSite().getViewSite());
    IHandlerService handlerService=(IHandlerService)navWorkSite.getSite().getService(IHandlerService.class);
    IHandler handler=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
      final ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
      if (coreService != null) {
        contextualsActions=coreService.getRepositoryContextualsActions();
        for (        ITreeContextualAction action : contextualsActions) {
          action.setWorkbenchPart(navWorkSite.getSite().getPart());
          if (action.getActionDefinitionId() != null) {
            handler=new ActionHandler(action);
            handlerService.activateHandler(action.getActionDefinitionId(),handler);
          }
        }
      }
    }
    doubleClickAction=new RepoDoubleClickAction(getActionSite().getStructuredViewer(),contextualsActions);
  }
}
Program: 128650
Project: 128650
Buggy source:
/** 
 * Constructor to use by a Wizard to create a new database connection.
 * @param existingNames
 * @param Composite
 * @param Wizard
 * @param ISelection
 */
public DatabaseForm(Composite parent,ConnectionItem connectionItem,String[] existingNames,boolean isCreation){
  super(parent,SWT.NONE,existingNames);
  this.connectionItem=connectionItem;
  this.isCreation=isCreation;
  setConnectionItem(connectionItem);
  this.metadataconnection=ConvertionHelper.convert(getConnection());
  this.typeName=EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType());
  if (typeName != null && typeName.isUseProvider()) {
    this.provider=ExtractMetaDataFromDataBase.getProviderByDbType(metadataconnection.getDbType());
  }
  setupForm(true);
  addStringConnectionControls();
  GridLayout layout2=(GridLayout)getLayout();
  layout2.marginHeight=0;
  setLayout(layout2);
}

Fixed version (ground truth):
/** 
 * Constructor to use by a Wizard to create a new database connection.
 * @param existingNames
 * @param Composite
 * @param Wizard
 * @param ISelection
 */
public DatabaseForm(Composite parent,ConnectionItem connectionItem,String[] existingNames,boolean isCreation){
  super(parent,SWT.NONE,existingNames);
  this.connectionItem=connectionItem;
  this.isCreation=isCreation;
  setConnectionItem(connectionItem);
  this.metadataconnection=ConvertionHelper.convert(getConnection(),true);
  this.typeName=EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType());
  if (typeName != null && typeName.isUseProvider()) {
    this.provider=ExtractMetaDataFromDataBase.getProviderByDbType(metadataconnection.getDbType());
  }
  setupForm(true);
  addStringConnectionControls();
  GridLayout layout2=(GridLayout)getLayout();
  layout2.marginHeight=0;
  setLayout(layout2);
}
Program: 128651
Project: 128651
Buggy source:
protected void doSave(OutputStream outputStream,Map options) throws IOException {
  ByteArray byteArray=(ByteArray)getContents().get(0);
  BufferedOutputStream bufferedOutputStream=new BufferedOutputStream(outputStream);
  bufferedOutputStream.write(byteArray.getInnerContent());
  bufferedOutputStream.flush();
}

Fixed version (ground truth):
@Override protected void doSave(OutputStream outputStream,Map options) throws IOException {
  if (getContents().size() > 0) {
    ByteArray byteArray=(ByteArray)getContents().get(0);
    BufferedOutputStream bufferedOutputStream=new BufferedOutputStream(outputStream);
    bufferedOutputStream.write(byteArray.getInnerContent());
    bufferedOutputStream.flush();
  }
}
Program: 128652
Project: 128652
Buggy source:
protected void doLoad(InputStream inputStream,Map options) throws IOException {
  BufferedInputStream bufferedInputStream=new BufferedInputStream(inputStream);
  byte[] content=new byte[bufferedInputStream.available()];
  bufferedInputStream.read(content);
  bufferedInputStream.close();
  ByteArray byteArray=PropertiesFactory.eINSTANCE.createByteArray();
  byteArray.setInnerContent(content);
  getContents().add(byteArray);
}

Fixed version (ground truth):
@Override protected void doLoad(InputStream inputStream,Map options) throws IOException {
  BufferedInputStream bufferedInputStream=new BufferedInputStream(inputStream);
  byte[] content=new byte[bufferedInputStream.available()];
  bufferedInputStream.read(content);
  bufferedInputStream.close();
  ByteArray byteArray=PropertiesFactory.eINSTANCE.createByteArray();
  byteArray.setInnerContent(content);
  getContents().add(byteArray);
}
Program: 128653
Project: 128653
Buggy source:
protected void doUnload(){
  super.doUnload();
}

Fixed version (ground truth):
@Override protected void doUnload(){
  super.doUnload();
}
Program: 128654
Project: 128654
Buggy source:
public static void deleteFile(File file,boolean delete){
  if (file.exists()) {
    if (file.isFile() && delete) {
      file.delete();
    }
 else     if (file.isDirectory()) {
      File files[]=file.listFiles();
      for (int i=0; i < files.length; i++) {
        deleteFile(files[i],true);
      }
    }
    if (delete) {
      file.delete();
    }
  }
}

Fixed version (ground truth):
public static void deleteFile(File file,boolean delete){
  if (file.exists()) {
    if (file.isFile() && delete) {
      file.delete();
    }
 else     if (file.isDirectory()) {
      File files[]=file.listFiles();
      for (      File file2 : files) {
        deleteFile(file2,true);
      }
    }
    if (delete) {
      file.delete();
    }
  }
}
Program: 128655
Project: 128655
Buggy source:
public static void copyDirectory(File source,File target){
  File tarpath=new File(target,source.getName());
  if (source.isDirectory()) {
    tarpath.mkdir();
    File[] dir=source.listFiles();
    for (int i=0; i < dir.length; i++) {
      copyDirectory(dir[i],tarpath);
    }
  }
 else {
    try {
      InputStream is=new FileInputStream(source);
      OutputStream os=new FileOutputStream(tarpath);
      byte[] buf=new byte[1024];
      int len=0;
      while ((len=is.read(buf)) != -1) {
        os.write(buf,0,len);
      }
      is.close();
      os.close();
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public static void copyDirectory(File source,File target){
  File tarpath=new File(target,source.getName());
  if (source.isDirectory()) {
    tarpath.mkdir();
    File[] dir=source.listFiles();
    for (    File element : dir) {
      copyDirectory(element,tarpath);
    }
  }
 else {
    try {
      InputStream is=new FileInputStream(source);
      OutputStream os=new FileOutputStream(tarpath);
      byte[] buf=new byte[1024];
      int len=0;
      while ((len=is.read(buf)) != -1) {
        os.write(buf,0,len);
      }
      is.close();
      os.close();
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    IOException e) {
      e.printStackTrace();
    }
  }
}