nus-yam/ex-repair huggingface dataset:
Program: 151452
Project: 151452
Buggy source:
@SuppressWarnings("String_Node_Str") public AeshUICommand(CommandContainer container){
  this.command=container.getCommand();
  this.commandLineParser=container.getParser();
  this.commandPopulator=commandLineParser.getCommandPopulator();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public AeshUICommand(CommandContainer container){
  this.command=container.getCommand();
  this.commandLineParser=container.getParser();
}
Program: 151453
Project: 151453
Buggy source:
@Override public void populateObject(Object instance,CommandLine line,InvocationProviders invocationProviders,boolean validate) throws CommandLineParserException, OptionValidatorException {
  commandPopulator.populateObject(command,line,invocationProviders,validate);
}

Fixed version (ground truth):
@Override public void populateObject(Object instance,CommandLine line,InvocationProviders invocationProviders,boolean validate) throws CommandLineParserException, OptionValidatorException {
  commandLineParser.getCommandPopulator().populateObject(command,line,invocationProviders,validate);
}
Program: 151454
Project: 151454
Buggy source:
@Override public CommandPopulator getCommandPopulator(){
  return new CommandPopulator(){
    @Override public void populateObject(    Object instance,    CommandLine line,    InvocationProviders invocationProviders,    boolean validate) throws CommandLineParserException, OptionValidatorException {
      commandPopulator.populateObject(command,line,invocationProviders,validate);
    }
  }
;
}

Fixed version (ground truth):
@Override public CommandPopulator getCommandPopulator(){
  return new CommandPopulator(){
    @Override public void populateObject(    Object instance,    CommandLine line,    InvocationProviders invocationProviders,    boolean validate) throws CommandLineParserException, OptionValidatorException {
      commandLineParser.getCommandPopulator().populateObject(command,line,invocationProviders,validate);
    }
  }
;
}
Program: 151455
Project: 151455
Buggy source:
@Override public CommandLineCompletionParser getCompletionParser(){
  return commandLineParser.getCompletionParser();
}

Fixed version (ground truth):
@Override public CommandLineCompletionParser getCompletionParser(){
  return new CommandLineCompletionParser(){
    @Override @SuppressWarnings("String_Node_Str") public void injectValuesAndComplete(    ParsedCompleteObject completeObject,    Command originalCommand,    CompleteOperation completeOperation,    InvocationProviders invocationProviders){
      commandLineParser.getCompletionParser().injectValuesAndComplete(completeObject,AeshUICommand.this.command,completeOperation,invocationProviders);
    }
    @Override public ParsedCompleteObject findCompleteObject(    String line,    int cursor) throws CommandLineParserException {
      return commandLineParser.getCompletionParser().findCompleteObject(line,cursor);
    }
  }
;
}
Program: 151456
Project: 151456
Buggy source:
@Override public List<Resource<?>> generateFrom(Project project,ScaffoldGenerationContext scaffoldContext){
  List<Resource<?>> generatedResources=new ArrayList<Resource<?>>();
  Collection<?> resources=scaffoldContext.getResources();
  for (  Object resource : resources) {
    JavaClass entity=(JavaClass)resource;
    String targetDir=scaffoldContext.getTargetDirectory();
    Resource<?> template=(Resource<?>)scaffoldContext.getAttribute("String_Node_Str");
    boolean overwrite=scaffoldContext.isOverwrite();
    List<Resource<?>> generatedResourcesForEntity=this.generateFromEntity(targetDir,template,entity,overwrite);
    generatedResources.addAll(generatedResourcesForEntity);
  }
  return generatedResources;
}

Fixed version (ground truth):
@Override public List<Resource<?>> generateFrom(Project project,ScaffoldGenerationContext scaffoldContext){
  List<Resource<?>> generatedResources=new ArrayList<Resource<?>>();
  Collection<?> resources=scaffoldContext.getResources();
  for (  Object resource : resources) {
    JavaClass entity=(JavaClass)resource;
    String targetDir=scaffoldContext.getTargetDirectory();
    targetDir=(targetDir == null) ? "String_Node_Str" : targetDir;
    Resource<?> template=(Resource<?>)scaffoldContext.getAttribute("String_Node_Str");
    boolean overwrite=scaffoldContext.isOverwrite();
    List<Resource<?>> generatedResourcesForEntity=this.generateFromEntity(targetDir,template,entity,overwrite);
    generatedResources.addAll(generatedResourcesForEntity);
  }
  return generatedResources;
}
Program: 151457
Project: 151457
Buggy source:
@Override public NavigationResult next(UIContext context) throws Exception {
  ResourceCollection resourceCollection=new ResourceCollection();
  for (  JavaClass klass : targets.getValue()) {
    resourceCollection.addToCollection(klass);
  }
  context.setAttribute(ResourceCollection.class,resourceCollection);
  ScaffoldGenerationContext genCtx=(ScaffoldGenerationContext)context.getAttribute(ScaffoldGenerationContext.class);
  genCtx.addAttribute("String_Node_Str",pageTemplate.getValue());
  return null;
}

Fixed version (ground truth):
@Override public NavigationResult next(UINavigationContext context) throws Exception {
  ResourceCollection resourceCollection=new ResourceCollection();
  for (  JavaClass klass : targets.getValue()) {
    resourceCollection.addToCollection(klass);
  }
  UIContext uiContext=context.getUIContext();
  uiContext.setAttribute(ResourceCollection.class,resourceCollection);
  ScaffoldGenerationContext genCtx=(ScaffoldGenerationContext)uiContext.getAttribute(ScaffoldGenerationContext.class);
  genCtx.addAttribute("String_Node_Str",pageTemplate.getValue());
  return null;
}
Program: 151458
Project: 151458
Buggy source:
@Override public NavigationResult next(UIContext context) throws Exception {
  return null;
}

Fixed version (ground truth):
@Override public NavigationResult next(UINavigationContext context) throws Exception {
  return null;
}
Program: 151459
Project: 151459
Buggy source:
@Override public NavigationResult next(UIContext context) throws Exception {
  return null;
}

Fixed version (ground truth):
@Override public NavigationResult next(UINavigationContext context) throws Exception {
  return null;
}
Program: 151460
Project: 151460
Buggy source:
@Override public NavigationResult next(UIContext context) throws Exception {
  ScaffoldProvider selectedProvider=provider.getValue();
  Project project=getSelectedProject(context);
  context.setAttribute(Project.class,project);
  context.setAttribute(ScaffoldProvider.class,selectedProvider);
  context.setAttribute(ScaffoldGenerationContext.class,populateGenerationContext(context));
  ((AbstractFacet)selectedProvider).setFaceted(project);
  List<Class<? extends UICommand>> generationFlow=selectedProvider.getGenerationFlow();
  generationFlow.add(ExecuteGenerationStep.class);
  Class<? extends UICommand> next=generationFlow.remove(0);
  Class<?>[] additional=generationFlow.toArray(new Class<?>[generationFlow.size()]);
  return Results.navigateTo(next,(Class<? extends UICommand>[])additional);
}

Fixed version (ground truth):
@Override public NavigationResult next(UINavigationContext context) throws Exception {
  ScaffoldProvider selectedProvider=provider.getValue();
  UIContext uiContext=context.getUIContext();
  Project project=getSelectedProject(uiContext);
  uiContext.setAttribute(Project.class,project);
  uiContext.setAttribute(ScaffoldProvider.class,selectedProvider);
  uiContext.setAttribute(ScaffoldGenerationContext.class,populateGenerationContext(uiContext));
  ((AbstractFacet)selectedProvider).setFaceted(project);
  List<Class<? extends UICommand>> generationFlow=selectedProvider.getGenerationFlow();
  generationFlow.add(ExecuteGenerationStep.class);
  Class<? extends UICommand> next=generationFlow.remove(0);
  Class<?>[] additional=generationFlow.toArray(new Class<?>[generationFlow.size()]);
  return Results.navigateTo(next,(Class<? extends UICommand>[])additional);
}
Program: 151461
Project: 151461
Buggy source:
@Override public NavigationResult next(UINavigationContext context) throws Exception {
  ScaffoldProvider selectedProvider=provider.getValue();
  Project project=getSelectedProject(context);
  ((AbstractFacet)selectedProvider).setFaceted(project);
  context.setAttribute(ScaffoldProvider.class,selectedProvider);
  context.setAttribute(ScaffoldSetupContext.class,createSetupContext());
  List<Class<? extends UICommand>> setupFlow=selectedProvider.getSetupFlow();
  setupFlow.add(ExecuteSetupStep.class);
  Class<? extends UICommand> next=setupFlow.remove(0);
  Class<?>[] additional=setupFlow.toArray(new Class<?>[setupFlow.size()]);
  return Results.navigateTo(next,(Class<? extends UICommand>[])additional);
}

Fixed version (ground truth):
@Override public NavigationResult next(UINavigationContext context) throws Exception {
  ScaffoldProvider selectedProvider=provider.getValue();
  Project project=getSelectedProject(context);
  ((AbstractFacet)selectedProvider).setFaceted(project);
  UIContext uiContext=context.getUIContext();
  uiContext.setAttribute(ScaffoldProvider.class,selectedProvider);
  uiContext.setAttribute(ScaffoldSetupContext.class,createSetupContext());
  List<Class<? extends UICommand>> setupFlow=selectedProvider.getSetupFlow();
  setupFlow.add(ExecuteSetupStep.class);
  Class<? extends UICommand> next=setupFlow.remove(0);
  Class<?>[] additional=setupFlow.toArray(new Class<?>[setupFlow.size()]);
  return context.navigateTo(next,(Class<? extends UICommand>[])additional);
}
Program: 151464
Project: 151464
Buggy source:
public void destroy(){
  if (this.shell != null)   this.shell.close();
}

Fixed version (ground truth):
public void destroy(){
  if (this.shell != null)   try {
    this.shell.close();
  }
 catch (  Exception e) {
    Logger.getLogger(getClass().getName()).log(Level.FINE,"String_Node_Str",e);
  }
}
Program: 151465
Project: 151465
Buggy source:
public static OptionCompleter getCompletionFor(InputComponent<?,Object> component,ShellContext context,ConverterFactory converterFactory){
  UISelection<FileResource<?>> selection=context.getInitialSelection();
  final File cwd=selection.isEmpty() ? OperatingSystemUtils.getUserHomeDir() : selection.get().getUnderlyingResourceObject();
  InputType inputType=component.getFacet(HintsFacet.class).getInputType();
  OptionCompleter strategy=null;
  if (inputType == InputType.FILE_PICKER && cwd.isDirectory()) {
    strategy=new FileOptionCompleter(cwd);
  }
 else   if (inputType == InputType.DIRECTORY_PICKER && cwd.isDirectory()) {
    strategy=new FileOptionCompleter(cwd,Filter.DIRECTORY);
  }
 else   if (inputType == InputType.CHECKBOX || Boolean.class.isAssignableFrom(component.getValueType())) {
    strategy=null;
  }
 else   if (component instanceof SelectComponent) {
    strategy=new SelectComponentOptionCompleter((SelectComponent<?,Object>)component,converterFactory);
  }
  strategy=new UICompleterOptionCompleter(strategy,context,component,converterFactory);
  return strategy;
}

Fixed version (ground truth):
public static OptionCompleter getCompletionFor(InputComponent<?,Object> component,ShellContext context,ConverterFactory converterFactory){
  UISelection<FileResource<?>> selection=context.getInitialSelection();
  final File cwd=selection.isEmpty() ? OperatingSystemUtils.getUserHomeDir() : selection.get().getUnderlyingResourceObject();
  InputType inputType=component.getFacet(HintsFacet.class).getInputType();
  OptionCompleter strategy=null;
  if (inputType == InputType.FILE_PICKER && cwd.isDirectory()) {
    strategy=new FileOptionCompleter(cwd);
  }
 else   if (inputType == InputType.DIRECTORY_PICKER && cwd.isDirectory()) {
    strategy=new FileOptionCompleter(cwd,Filter.DIRECTORY);
  }
 else   if (component instanceof SelectComponent) {
    strategy=new SelectComponentOptionCompleter((SelectComponent<?,Object>)component,converterFactory);
  }
  strategy=new UICompleterOptionCompleter(strategy,context,component,converterFactory);
  return strategy;
}
Program: 151466
Project: 151466
Buggy source:
@Override public Result execute(ShellContext context) throws Exception {
  Shell shell=context.getProvider();
  FileResource<?> currentResource=shell.getCurrentResource();
  Iterator<String> it=arguments.getValue().iterator();
  final Result result;
  if (it.hasNext()) {
    String newPath=it.next();
    final List<Resource<?>> newResource=new PathspecParser(resourceFactory,currentResource,newPath).resolve();
    if (newResource.isEmpty() || !newResource.get(0).exists()) {
      result=Results.fail(newPath + "String_Node_Str");
    }
 else {
      FileResource<?> newFileResource=newResource.get(0).reify(FileResource.class);
      if (newFileResource == null) {
        result=Results.fail(newPath + "String_Node_Str");
      }
 else {
        shell.setCurrentResource(newFileResource);
        result=Results.success();
      }
    }
  }
 else {
    result=Results.success();
  }
  return result;
}

Fixed version (ground truth):
@Override public Result execute(ShellContext context) throws Exception {
  Shell shell=context.getProvider();
  FileResource<?> currentResource=shell.getCurrentResource();
  Iterable<String> value=arguments.getValue();
  Iterator<String> it=value == null ? Collections.<String>emptyList().iterator() : value.iterator();
  final Result result;
  if (it.hasNext()) {
    String newPath=it.next();
    final List<Resource<?>> newResource=new PathspecParser(resourceFactory,currentResource,newPath).resolve();
    if (newResource.isEmpty() || !newResource.get(0).exists()) {
      result=Results.fail(newPath + "String_Node_Str");
    }
 else {
      FileResource<?> newFileResource=newResource.get(0).reify(FileResource.class);
      if (newFileResource == null) {
        result=Results.fail(newPath + "String_Node_Str");
      }
 else {
        shell.setCurrentResource(newFileResource);
        result=Results.success();
      }
    }
  }
 else {
    result=Results.success();
  }
  return result;
}
Program: 151467
Project: 151467
Buggy source:
@Override public void initializeUI(UIBuilder builder) throws Exception {
  UIContext uiContext=builder.getUIContext();
  PersistenceContainer pc=(PersistenceContainer)uiContext.getAttribute(PersistenceContainer.class);
  initDBType(uiContext);
  initDatasourceName(uiContext);
  builder.add(persistenceUnitName.setDefaultValue(PersistenceOperations.DEFAULT_UNIT_NAME));
  builder.add(dbType);
  if (pc.isJTASupported()) {
    builder.add(dataSourceName);
  }
 else {
    builder.add(jdbcDriver).add(databaseURL).add(username).add(password);
  }
}

Fixed version (ground truth):
@Override public void initializeUI(UIBuilder builder) throws Exception {
  UIContext uiContext=builder.getUIContext();
  PersistenceContainer pc=(PersistenceContainer)uiContext.getAttribute(PersistenceContainer.class);
  initDBType(uiContext);
  initDatasourceName(uiContext);
  initPersistenceUnitName(builder);
  builder.add(dbType);
  if (pc.isJTASupported()) {
    builder.add(dataSourceName);
  }
 else {
    builder.add(jdbcDriver).add(databaseURL).add(username).add(password);
  }
}
Program: 151468
Project: 151468
Buggy source:
@Override public void validate(UIValidationContext validator){
  UIContext uiContext=validator.getUIContext();
  JPADataSource ds=getDataSource(uiContext);
  try {
    ds.validate();
  }
 catch (  Exception e) {
    validator.addValidationError(null,e.getMessage());
  }
  Project project=getSelectedProject(uiContext);
  if (project.hasFacet(PersistenceFacet.class)) {
    PersistenceDescriptor config=project.getFacet(PersistenceFacet.class).getConfig();
    for (    PersistenceUnit<PersistenceDescriptor> persistenceUnit : config.getAllPersistenceUnit()) {
      if (persistenceUnitName.getValue().equals(persistenceUnit.getName())) {
        validator.addValidationError(persistenceUnitName,"String_Node_Str");
        break;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void validate(UIValidationContext validator){
  UIContext uiContext=validator.getUIContext();
  JPADataSource ds=getDataSource(uiContext);
  try {
    ds.validate();
  }
 catch (  Exception e) {
    validator.addValidationError(null,e.getMessage());
  }
  Project project=getSelectedProject(uiContext);
  if (isExistingPersistenceUnitName(project,persistenceUnitName.getValue())) {
    validator.addValidationError(persistenceUnitName,"String_Node_Str");
  }
}
Program: 151469
Project: 151469
Buggy source:
@Override public void initializeUI(UIBuilder builder) throws Exception {
  idStrategy.setDefaultValue(GenerationType.AUTO);
  Project project=getSelectedProject(builder.getUIContext());
  if (project == null) {
    UISelection<FileResource<?>> currentSelection=builder.getUIContext().getInitialSelection();
    if (!currentSelection.isEmpty()) {
      FileResource<?> resource=currentSelection.get();
      if (resource instanceof DirectoryResource) {
        targetLocation.setDefaultValue((DirectoryResource)resource);
      }
 else {
        targetLocation.setDefaultValue(resource.getParent());
      }
    }
  }
 else {
    JavaSourceFacet facet=project.getFacet(JavaSourceFacet.class);
    targetLocation.setDefaultValue(facet.getSourceFolder()).setEnabled(false);
  }
  builder.add(targetLocation);
  builder.add(targetPackage).add(named).add(idStrategy);
}

Fixed version (ground truth):
@Override public void initializeUI(UIBuilder builder) throws Exception {
  idStrategy.setDefaultValue(GenerationType.AUTO);
  Project project=getSelectedProject(builder.getUIContext());
  if (project == null) {
    UISelection<FileResource<?>> currentSelection=builder.getUIContext().getInitialSelection();
    if (!currentSelection.isEmpty()) {
      FileResource<?> resource=currentSelection.get();
      if (resource instanceof DirectoryResource) {
        targetLocation.setDefaultValue((DirectoryResource)resource);
      }
 else {
        targetLocation.setDefaultValue(resource.getParent());
      }
    }
  }
 else   if (project.hasFacet(JavaSourceFacet.class)) {
    JavaSourceFacet facet=project.getFacet(JavaSourceFacet.class);
    targetLocation.setDefaultValue(facet.getSourceFolder()).setEnabled(false);
  }
  builder.add(targetLocation);
  builder.add(targetPackage).add(named).add(idStrategy);
}
Program: 151470
Project: 151470
Buggy source:
public void startupDefaultShell(@Observes PostStartup startup) throws Exception {
  if (!Boolean.getBoolean("String_Node_Str")) {
    Settings settings=new SettingsBuilder().create();
    this.shell=shellFactory.createShell(OperatingSystemUtils.getUserHomeDir(),settings);
  }
}

Fixed version (ground truth):
public void startupDefaultShell(@Observes PostStartup startup) throws Exception {
  if (!Boolean.getBoolean("String_Node_Str")) {
    Settings settings=new SettingsBuilder().create();
    this.shell=shellFactory.createShell(OperatingSystemUtils.getWorkingDir(),settings);
  }
}
Program: 151471
Project: 151471
Buggy source:
@Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  completeOperation.setOffset(completeOperation.getCursor());
  final File cwd;
  Object value=InputComponents.getValueFor(input);
  if (value == null) {
    UISelection<FileResource<?>> selection=context.getInitialSelection();
    cwd=selection.isEmpty() ? OperatingSystemUtils.getUserHomeDir() : selection.get().getUnderlyingResourceObject();
  }
 else {
    cwd=new File(value.toString());
  }
  FileLister fileLister=new FileLister(typedValue == null ? "String_Node_Str" : Parser.switchEscapedSpacesToSpacesInWord(typedValue),cwd,directory ? FileLister.Filter.DIRECTORY : FileLister.Filter.ALL);
  fileLister.findMatchingDirectories(completeOperation);
  if (completeOperation.getCompletionCandidates().size() > 1)   completeOperation.removeEscapedSpacesFromCompletionCandidates();
}

Fixed version (ground truth):
@Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  completeOperation.setOffset(completeOperation.getCursor());
  final File cwd;
  Object value=InputComponents.getValueFor(input);
  if (value == null) {
    UISelection<FileResource<?>> selection=context.getInitialSelection();
    cwd=selection.isEmpty() ? OperatingSystemUtils.getUserHomeDir() : selection.get().getUnderlyingResourceObject();
  }
 else {
    cwd=new File(value.toString());
  }
  FileLister fileLister=new FileLister(typedValue == null ? "String_Node_Str" : Parser.switchEscapedSpacesToSpacesInWord(typedValue),cwd,directory ? FileLister.Filter.DIRECTORY : FileLister.Filter.ALL);
  fileLister.findMatchingDirectories(completeOperation);
}
Program: 151473
Project: 151473
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  SelectComponent<?,Object> selectComponent=(SelectComponent<?,Object>)input;
  Converter<Object,String> itemLabelConverter=(Converter<Object,String>)InputComponents.getItemLabelConverter(converterFactory,selectComponent);
  boolean noTypedValue=Strings.isNullOrEmpty(typedValue);
  Iterable<Object> valueChoices=selectComponent.getValueChoices();
  for (  Object choice : valueChoices) {
    String convert=itemLabelConverter.convert(choice);
    if (noTypedValue || convert.startsWith(typedValue)) {
      completeOperation.addCompletionCandidate(convert);
    }
  }
  if (!completeOperation.getCompletionCandidates().isEmpty() && !noTypedValue) {
    completeOperation.setOffset(completeOperation.getCursor() - typedValue.length());
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void complete(final CompleteOperation completeOperation,final InputComponent<?,Object> input,final ShellContext context,final String typedValue,final ConverterFactory converterFactory){
  SelectComponent<?,Object> selectComponent=(SelectComponent<?,Object>)input;
  Converter<Object,String> itemLabelConverter=(Converter<Object,String>)InputComponents.getItemLabelConverter(converterFactory,selectComponent);
  Iterable<Object> valueChoices=selectComponent.getValueChoices();
  List<String> choices=new ArrayList<String>();
  for (  Object choice : valueChoices) {
    String convert=itemLabelConverter.convert(choice);
    if (convert != null) {
      choices.add(convert);
    }
  }
  if (choices.size() > 1) {
    String startsWith=Parser.findStartsWith(choices);
    if (startsWith != null && startsWith.length() > 0 && startsWith.length() > typedValue.length()) {
      String substring=startsWith.substring(typedValue.length());
      String candidate=Parser.switchSpacesToEscapedSpacesInWord(substring);
      completeOperation.addCompletionCandidate(candidate);
      completeOperation.setOffset(completeOperation.getCursor() - typedValue.length());
    }
 else {
      completeOperation.addCompletionCandidates(choices);
      if (!completeOperation.getCompletionCandidates().isEmpty() && !typedValue.isEmpty()) {
        completeOperation.setOffset(completeOperation.getCursor() - typedValue.length());
      }
    }
  }
 else   if (choices.size() == 1) {
    completeOperation.addCompletionCandidate(choices.get(0).substring(typedValue.length()));
    if (!completeOperation.getCompletionCandidates().isEmpty() && !typedValue.isEmpty()) {
      completeOperation.setOffset(completeOperation.getCursor() - typedValue.length());
    }
  }
}
Program: 151474
Project: 151474
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  UICompleter<Object> completer=InputComponents.getCompleterFor(input);
  if (completer != null) {
    final Converter<Object,String> converter;
    if (input instanceof SelectComponent) {
      converter=(Converter<Object,String>)InputComponents.getItemLabelConverter(converterFactory,(SelectComponent<?,?>)input);
    }
 else {
      converter=converterFactory.getConverter(input.getValueType(),String.class);
    }
    for (    Object proposal : completer.getCompletionProposals(context,input,typedValue)) {
      if (proposal != null) {
        String convertedValue=converter.convert(proposal);
        completeOperation.addCompletionCandidate(convertedValue);
      }
    }
    if (!completeOperation.getCompletionCandidates().isEmpty() && !Strings.isNullOrEmpty(typedValue)) {
      completeOperation.setOffset(completeOperation.getCursor() - typedValue.length());
    }
  }
 else {
    if (fallback != null) {
      fallback.complete(completeOperation,input,context,typedValue,converterFactory);
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  UICompleter<Object> completer=InputComponents.getCompleterFor(input);
  if (completer != null) {
    final Converter<Object,String> converter;
    if (input instanceof SelectComponent) {
      converter=(Converter<Object,String>)InputComponents.getItemLabelConverter(converterFactory,(SelectComponent<?,?>)input);
    }
 else {
      converter=converterFactory.getConverter(input.getValueType(),String.class);
    }
    List<String> choices=new ArrayList<String>();
    for (    Object proposal : completer.getCompletionProposals(context,input,typedValue)) {
      if (proposal != null) {
        String convertedValue=Parser.switchSpacesToEscapedSpacesInWord(converter.convert(proposal));
        choices.add(convertedValue);
      }
    }
    if (choices.size() > 1) {
      String startsWith=Parser.findStartsWith(choices);
      if (startsWith != null && startsWith.length() > 0 && startsWith.length() > typedValue.length()) {
        completeOperation.addCompletionCandidate(Parser.switchSpacesToEscapedSpacesInWord(startsWith.substring(typedValue.length())));
      }
 else {
        completeOperation.addCompletionCandidates(choices);
      }
    }
 else     if (choices.size() == 1) {
      completeOperation.addCompletionCandidate(choices.get(0).substring(typedValue.length()));
    }
    if (!completeOperation.getCompletionCandidates().isEmpty() && !Strings.isNullOrEmpty(typedValue)) {
      completeOperation.setOffset(completeOperation.getCursor() - typedValue.length());
    }
  }
 else {
    if (fallback != null) {
      fallback.complete(completeOperation,input,context,typedValue,converterFactory);
    }
  }
}
Program: 151475
Project: 151475
Buggy source:
@Test public void testValuesWithSpaceCompletion() throws Exception {
  test.waitForCompletion("String_Node_Str","String_Node_Str",5,TimeUnit.SECONDS);
  test.waitForCompletion("String_Node_Str","String_Node_Str",5,TimeUnit.SECONDS);
}

Fixed version (ground truth):
@Test public void testValuesWithSpaceCompletion() throws Exception {
  test.waitForCompletion("String_Node_Str","String_Node_Str",5,TimeUnit.SECONDS);
}
Program: 151476
Project: 151476
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  SelectComponent<?,Object> selectComponent=(SelectComponent<?,Object>)input;
  Converter<Object,String> itemLabelConverter=(Converter<Object,String>)InputComponents.getItemLabelConverter(converterFactory,selectComponent);
  Iterable<Object> valueChoices=selectComponent.getValueChoices();
  for (  Object choice : valueChoices) {
    String convert=itemLabelConverter.convert(choice);
    if (Strings.isNullOrEmpty(convert) || convert.startsWith(typedValue)) {
      completeOperation.addCompletionCandidate(convert);
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void complete(CompleteOperation completeOperation,InputComponent<?,Object> input,ShellContext context,String typedValue,ConverterFactory converterFactory){
  SelectComponent<?,Object> selectComponent=(SelectComponent<?,Object>)input;
  Converter<Object,String> itemLabelConverter=(Converter<Object,String>)InputComponents.getItemLabelConverter(converterFactory,selectComponent);
  boolean noTypedValue=Strings.isNullOrEmpty(typedValue);
  Iterable<Object> valueChoices=selectComponent.getValueChoices();
  for (  Object choice : valueChoices) {
    String convert=itemLabelConverter.convert(choice);
    if (noTypedValue || convert.startsWith(typedValue)) {
      completeOperation.addCompletionCandidate(convert);
    }
  }
}
Program: 151478
Project: 151478
Buggy source:
@Override public void populateInputs(String line,boolean lenient) throws CommandLineParserException {
  CommandLine commandLine=getParser().parse(line,false,lenient);
  this.commandLineUtil.populateUIInputs(commandLine,inputs);
}

Fixed version (ground truth):
@Override public void populateInputs(String line,boolean lenient) throws CommandLineParserException {
  CommandLine commandLine=getParser().parse(line,lenient);
  this.commandLineUtil.populateUIInputs(commandLine,inputs);
}
Program: 151479
Project: 151479
Buggy source:
@Override public void populateInputs(String line,boolean lenient) throws CommandLineParserException {
  UIWizard command=getSourceCommand();
  try {
    fullCommandLineParser=populate(command,command,line,true);
    if (!lenient) {
      fullCommandLineParser.parse(line,false,false);
    }
  }
 catch (  CommandLineParserException cpe) {
    throw cpe;
  }
catch (  Exception e) {
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
@Override public void populateInputs(String line,boolean lenient) throws CommandLineParserException {
  UIWizard command=getSourceCommand();
  try {
    fullCommandLineParser=populate(command,command,line,true);
    if (!lenient) {
      fullCommandLineParser.parse(line,false);
    }
  }
 catch (  CommandLineParserException cpe) {
    throw cpe;
  }
catch (  Exception e) {
    throw new IllegalStateException(e);
  }
}
Program: 151480
Project: 151480
Buggy source:
@SuppressWarnings("String_Node_Str") private CommandLineParser populate(UIWizard root,UIWizard current,String line,boolean lenient) throws Exception {
  addWizardStep(current);
  Map<String,InputComponent<?,Object>> inputs=getInputs();
  CommandLineParser parser=commandLineUtil.generateParser(root,inputs);
  CommandLine cmdLine=parser.parse(line,lenient,lenient);
  commandLineUtil.populateUIInputs(cmdLine,inputs);
  List<String> errors=validate();
  if (errors.isEmpty()) {
    NavigationResult next=current.next(getContext());
    if (next != null && next.getNext() != null) {
      Class<? extends UIWizardStep> nextWizardStep=(Class<? extends UIWizardStep>)next.getNext();
      UIWizardStep step=commandManager.lookup(nextWizardStep);
      parser=populate(root,step,line,lenient);
    }
  }
  return parser;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private CommandLineParser populate(UIWizard root,UIWizard current,String line,boolean lenient) throws Exception {
  addWizardStep(current);
  Map<String,InputComponent<?,Object>> inputs=getInputs();
  CommandLineParser parser=commandLineUtil.generateParser(root,inputs);
  CommandLine cmdLine=parser.parse(line,lenient);
  commandLineUtil.populateUIInputs(cmdLine,inputs);
  List<String> errors=validate();
  if (errors.isEmpty()) {
    NavigationResult next=current.next(getContext());
    if (next != null && next.getNext() != null) {
      Class<? extends UIWizardStep> nextWizardStep=(Class<? extends UIWizardStep>)next.getNext();
      UIWizardStep step=commandManager.lookup(nextWizardStep);
      parser=populate(root,step,line,lenient);
    }
  }
  return parser;
}
Program: 151481
Project: 151481
Buggy source:
public CommandLineParser generateParser(UICommand command,Map<String,InputComponent<?,Object>> inputs){
  ParserBuilder builder=new ParserBuilder();
  UICommandMetadata metadata=command.getMetadata();
  ParameterInt parameter=new ParameterInt(ShellUtil.shellifyName(metadata.getName()),metadata.getDescription());
  for (  InputComponent<?,Object> input : inputs.values()) {
    if (!input.getName().equals("String_Node_Str")) {
      Object defaultValue=InputComponents.getValueFor(input);
      boolean isMultiple=input instanceof ManyValued;
      boolean hasValue=(InputComponents.getInputType(input) != InputType.CHECKBOX);
      try {
        OptionBuilder optionBuilder=new OptionBuilder();
        optionBuilder.name(input.getName()).defaultValue(defaultValue == null ? null : defaultValue.toString()).description(input.getLabel()).hasMultipleValues(isMultiple).hasValue(hasValue).required(input.isRequired());
        if (input.getShortName() != InputComponents.DEFAULT_SHORT_NAME) {
          optionBuilder.shortName(input.getShortName());
        }
        parameter.addOption(optionBuilder.create());
      }
 catch (      OptionParserException e) {
        logger.log(Level.SEVERE,"String_Node_Str",e);
      }
    }
  }
  builder.parameter(parameter);
  return builder.generateParser();
}

Fixed version (ground truth):
public CommandLineParser generateParser(UICommand command,Map<String,InputComponent<?,Object>> inputs){
  ParserBuilder builder=new ParserBuilder();
  UICommandMetadata metadata=command.getMetadata();
  ParameterInt parameter=new ParameterInt(ShellUtil.shellifyName(metadata.getName()),metadata.getDescription());
  for (  InputComponent<?,Object> input : inputs.values()) {
    Object defaultValue=InputComponents.getValueFor(input);
    boolean isMultiple=input instanceof ManyValued;
    boolean hasValue=(InputComponents.getInputType(input) != InputType.CHECKBOX);
    try {
      OptionBuilder optionBuilder=new OptionBuilder();
      optionBuilder.name(input.getName()).defaultValue(defaultValue == null ? null : defaultValue.toString()).description(input.getLabel()).hasMultipleValues(isMultiple).hasValue(hasValue).required(input.isRequired());
      if (input.getShortName() != InputComponents.DEFAULT_SHORT_NAME) {
        optionBuilder.shortName(input.getShortName());
      }
      OptionInt option=optionBuilder.create();
      if (input.getName().equals("String_Node_Str")) {
        parameter.setArgument(option);
      }
 else {
        parameter.addOption(option);
      }
    }
 catch (    OptionParserException e) {
      logger.log(Level.SEVERE,"String_Node_Str",e);
    }
  }
  builder.parameter(parameter);
  return builder.generateParser();
}
Program: 151482
Project: 151482
Buggy source:
@SuppressWarnings("String_Node_Str") public void populateUIInputs(CommandLine commandLine,Map<String,InputComponent<?,Object>> inputs){
  for (  InputComponent<?,Object> input : inputs.values()) {
    if (input.getName().equals("String_Node_Str") && input instanceof UIInputMany) {
      InputComponents.setValueFor(converterFactory,input,commandLine.getArgument());
    }
 else     if (input instanceof UIInputMany) {
      InputComponents.setValueFor(converterFactory,input,commandLine.getOptionValues(input.getName()));
    }
 else     if (input instanceof UIInput) {
      InputComponents.setValueFor(converterFactory,input,commandLine.getOptionValue(input.getName()));
    }
 else     if (input instanceof UISelectMany) {
      setInputChoices((UISelectMany<Object>)input,commandLine.getOptionValues(input.getName()));
    }
 else     if (input instanceof UISelectOne) {
      setInputChoice((UISelectOne<Object>)input,commandLine.getOptionValue(input.getName()));
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void populateUIInputs(CommandLine commandLine,Map<String,InputComponent<?,Object>> inputs){
  for (  InputComponent<?,Object> input : inputs.values()) {
    if (input.getName().equals("String_Node_Str") && input instanceof UIInputMany) {
      InputComponents.setValueFor(converterFactory,input,commandLine.getArgument().getValue());
    }
 else     if (input instanceof UIInputMany) {
      InputComponents.setValueFor(converterFactory,input,commandLine.getOptionValues(input.getName()));
    }
 else     if (input instanceof UIInput) {
      InputComponents.setValueFor(converterFactory,input,commandLine.getOptionValue(input.getName()));
    }
 else     if (input instanceof UISelectMany) {
      setInputChoices((UISelectMany<Object>)input,commandLine.getOptionValues(input.getName()));
    }
 else     if (input instanceof UISelectOne) {
      setInputChoice((UISelectOne<Object>)input,commandLine.getOptionValue(input.getName()));
    }
  }
}
Program: 151483
Project: 151483
Buggy source:
@PreDestroy public void destroyShell() throws Exception {
  if (this.shell != null) {
    this.shell.close();
    this.shell=null;
  }
}

Fixed version (ground truth):
@PreDestroy public void destroyShell(){
  if (this.shell != null) {
    this.shell.close();
    this.shell=null;
  }
}
Program: 151484
Project: 151484
Buggy source:
public void shutdown(@Observes PreShutdown preShutdown) throws Exception {
  destroyShell();
}

Fixed version (ground truth):
public void shutdown(@Observes PreShutdown preShutdown){
  destroyShell();
}
Program: 151486
Project: 151486
Buggy source:
@SuppressWarnings({"String_Node_Str"}) private void defaultCompletion(CompleteOperation completeOperation) throws CommandLineParserException {
  InputComponent inputOption=context.findInput("String_Node_Str");
  if (inputOption != null) {
    argumentCompletion(completeOperation,new CommandLineCompletionParser(context.getParser()).findCompleteObject(completeOperation.getBuffer()));
  }
 else {
    completeOperation.addCompletionCandidates(context.getParser().getParameter().getOptionLongNamesWithDash());
  }
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str"}) private void defaultCompletion(CompleteOperation completeOperation) throws CommandLineParserException {
  InputComponent inputOption=context.findInput("String_Node_Str");
  if (inputOption != null) {
    argumentCompletion(completeOperation,new CommandLineCompletionParser(context.getParser()).findCompleteObject(completeOperation.getBuffer()));
  }
 else {
    completeOperation.addCompletionCandidates(context.getParser().getParameters().get(0).getOptionLongNamesWithDash());
  }
}
Program: 151487
Project: 151487
Buggy source:
public static CommandLineParser generateParser(UICommand command,ShellContext context){
  ParserBuilder builder=new ParserBuilder();
  ParameterInt parameter=new ParameterInt(command.getMetadata().getName(),command.getMetadata().getDescription());
  for (  InputComponent<?,?> input : context.getInputs()) {
    if (!input.getName().equals("String_Node_Str")) {
      try {
        if (input.getValueType() == Boolean.class) {
          parameter.addOption(new OptionBuilder().longName(input.getName()).hasValue(false).description(input.getLabel()).create());
        }
 else {
          parameter.addOption(new OptionBuilder().longName(input.getName()).description(input.getLabel()).required(input.isRequired()).create());
        }
      }
 catch (      OptionParserException e) {
      }
    }
  }
  builder.parameter(parameter);
  return builder.generateParser();
}

Fixed version (ground truth):
public static CommandLineParser generateParser(UICommand command,ShellContext context){
  ParserBuilder builder=new ParserBuilder();
  ParameterInt parameter=new ParameterInt(command.getMetadata().getName(),command.getMetadata().getDescription());
  for (  InputComponent<?,?> input : context.getInputs()) {
    if (!input.getName().equals("String_Node_Str")) {
      try {
        if (input.getValueType() == Boolean.class) {
          parameter.addOption(new OptionBuilder().longName(input.getName()).hasValue(false).description(input.getLabel()).create());
        }
 else {
          parameter.addOption(new OptionBuilder().longName(input.getName()).description(input.getLabel()).required(input.isRequired()).create());
        }
      }
 catch (      OptionParserException e) {
      }
    }
  }
  builder.addParameter(parameter);
  return builder.generateParser();
}
Program: 151488
Project: 151488
Buggy source:
@Test public void testGenerateParser() throws Exception {
  ShellContext context=new ShellContext(null);
  Foo1Command foo1=new Foo1Command();
  foo1.initializeUI(context);
  CommandLineParser parser=CommandLineUtil.generateParser(foo1,context);
  assertEquals("String_Node_Str",parser.getParameter().getName());
  Foo2Command foo2=new Foo2Command();
  foo2.initializeUI(context);
  parser=CommandLineUtil.generateParser(foo2,context);
  ParameterInt param=parser.getParameter();
  assertEquals("String_Node_Str",param.getName());
  assertEquals("String_Node_Str",param.findLongOption("String_Node_Str").getName());
  assertEquals("String_Node_Str",param.findLongOption("String_Node_Str").getName());
}

Fixed version (ground truth):
@Test public void testGenerateParser() throws Exception {
  ShellContext context=new ShellContext(null);
  Foo1Command foo1=new Foo1Command();
  foo1.initializeUI(context);
  CommandLineParser parser=CommandLineUtil.generateParser(foo1,context);
  assertEquals("String_Node_Str",parser.getParameters().get(0).getName());
  Foo2Command foo2=new Foo2Command();
  foo2.initializeUI(context);
  parser=CommandLineUtil.generateParser(foo2,context);
  ParameterInt param=parser.getParameters().get(0);
  assertEquals("String_Node_Str",param.getName());
  assertEquals("String_Node_Str",param.findLongOption("String_Node_Str").getName());
  assertEquals("String_Node_Str",param.findLongOption("String_Node_Str").getName());
}
Program: 151490
Project: 151490
Buggy source:
private DependencyNode traverseAddonGraph(String coords,RepositorySystem system,Settings settings,DefaultRepositorySystemSession session){
  session.setDependencyTraverser(new DependencyTraverser(){
    @Override public boolean traverseDependency(    Dependency dependency){
      boolean isForgeAddon="String_Node_Str".equals(dependency.getArtifact().getClassifier());
      if (!isForgeAddon && dependency.isOptional()) {
        return false;
      }
      boolean shouldRecurse=!"String_Node_Str".equals(dependency.getScope());
      return shouldRecurse;
    }
    @Override public DependencyTraverser deriveChildTraverser(    DependencyCollectionContext context){
      return this;
    }
  }
);
  session.setDependencySelector(new AddonDependencySelector());
  Artifact queryArtifact=new DefaultArtifact(coords);
  CollectRequest collectRequest=new CollectRequest(new Dependency(queryArtifact,null),container.getEnabledRepositoriesFromProfile(settings));
  CollectResult result;
  try {
    result=system.collectDependencies(session,collectRequest);
  }
 catch (  DependencyCollectionException e) {
    throw new RuntimeException(e);
  }
  return result.getRoot();
}

Fixed version (ground truth):
private DependencyNode traverseAddonGraph(String coords,RepositorySystem system,Settings settings,DefaultRepositorySystemSession session){
  session.setDependencyTraverser(new DependencyTraverser(){
    @Override public boolean traverseDependency(    Dependency dependency){
      boolean isForgeAddon="String_Node_Str".equals(dependency.getArtifact().getClassifier());
      if (!isForgeAddon && dependency.isOptional()) {
        return false;
      }
      boolean shouldRecurse=!"String_Node_Str".equals(dependency.getScope());
      return shouldRecurse;
    }
    @Override public DependencyTraverser deriveChildTraverser(    DependencyCollectionContext context){
      return this;
    }
  }
);
  session.setDependencySelector(new AddonDependencySelector());
  Artifact queryArtifact=new DefaultArtifact(coords);
  List<RemoteRepository> repositories=MavenRepositories.getRemoteRepositories(container,settings);
  CollectRequest collectRequest=new CollectRequest(new Dependency(queryArtifact,null),repositories);
  CollectResult result;
  try {
    result=system.collectDependencies(session,collectRequest);
  }
 catch (  DependencyCollectionException e) {
    throw new RuntimeException(e);
  }
  return result.getRoot();
}
Program: 151491
Project: 151491
Buggy source:
private VersionRangeResult getVersions(String addonName,String version){
  try {
    String[] split=addonName.split("String_Node_Str");
    if (split.length == 2) {
      version=split[1];
    }
    if (version == null || version.isEmpty()) {
      version="String_Node_Str";
    }
 else     if (!version.matches("String_Node_Str")) {
      version="String_Node_Str" + version + "String_Node_Str";
    }
    RepositorySystem system=container.getRepositorySystem();
    Settings settings=container.getSettings();
    DefaultRepositorySystemSession session=container.setupRepoSession(system,settings);
    Artifact artifact=new DefaultArtifact(toMavenCoords(AddonId.from(addonName,version)));
    List<RemoteRepository> remoteRepos=container.getEnabledRepositoriesFromProfile(settings);
    VersionRangeRequest rangeRequest=new VersionRangeRequest(artifact,remoteRepos,null);
    VersionRangeResult rangeResult=system.resolveVersionRange(session,rangeRequest);
    return rangeResult;
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + addonName + "String_Node_Str",e);
  }
}

Fixed version (ground truth):
private VersionRangeResult getVersions(String addonName,String version){
  try {
    String[] split=addonName.split("String_Node_Str");
    if (split.length == 2) {
      version=split[1];
    }
    if (version == null || version.isEmpty()) {
      version="String_Node_Str";
    }
 else     if (!version.matches("String_Node_Str")) {
      version="String_Node_Str" + version + "String_Node_Str";
    }
    RepositorySystem system=container.getRepositorySystem();
    Settings settings=container.getSettings();
    DefaultRepositorySystemSession session=container.setupRepoSession(system,settings);
    Artifact artifact=new DefaultArtifact(toMavenCoords(AddonId.from(addonName,version)));
    List<RemoteRepository> repositories=MavenRepositories.getRemoteRepositories(container,settings);
    VersionRangeRequest rangeRequest=new VersionRangeRequest(artifact,repositories,null);
    VersionRangeResult rangeResult=system.resolveVersionRange(session,rangeRequest);
    return rangeResult;
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + addonName + "String_Node_Str",e);
  }
}
Program: 151492
Project: 151492
Buggy source:
@Override public Dependency resolveArtifact(DependencyQuery query){
  RepositorySystem system=container.getRepositorySystem();
  Settings settings=container.getSettings();
  List<RemoteRepository> remoteRepos=getRemoteRepositories(query,settings);
  MavenRepositorySystemSession session=container.setupRepoSession(system,settings);
  Artifact queryArtifact=coordinateToMavenArtifact(query.getCoordinate());
  ArtifactRequest request=new ArtifactRequest(queryArtifact,remoteRepos,null);
  try {
    ArtifactResult resolvedArtifact=system.resolveArtifact(session,request);
    Artifact artifact=resolvedArtifact.getArtifact();
    @SuppressWarnings("String_Node_Str") FileResource<?> artifactResource=factory.create(FileResource.class,artifact.getFile());
    return DependencyBuilder.create().setArtifact(artifactResource).setGroupId(artifact.getGroupId()).setArtifactId(artifact.getArtifactId()).setClassifier(artifact.getClassifier()).setPackaging(artifact.getExtension()).setVersion(artifact.getBaseVersion());
  }
 catch (  ArtifactResolutionException e) {
    throw new MavenOperationException(e);
  }
}

Fixed version (ground truth):
@Override public Dependency resolveArtifact(DependencyQuery query){
  RepositorySystem system=container.getRepositorySystem();
  Settings settings=container.getSettings();
  List<RemoteRepository> remoteRepos=MavenRepositories.getRemoteRepositories(container,settings,query);
  MavenRepositorySystemSession session=container.setupRepoSession(system,settings);
  Artifact queryArtifact=MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());
  ArtifactRequest request=new ArtifactRequest(queryArtifact,remoteRepos,null);
  try {
    ArtifactResult resolvedArtifact=system.resolveArtifact(session,request);
    Artifact artifact=resolvedArtifact.getArtifact();
    @SuppressWarnings("String_Node_Str") FileResource<?> artifactResource=factory.create(FileResource.class,artifact.getFile());
    return DependencyBuilder.create().setArtifact(artifactResource).setGroupId(artifact.getGroupId()).setArtifactId(artifact.getArtifactId()).setClassifier(artifact.getClassifier()).setPackaging(artifact.getExtension()).setVersion(artifact.getBaseVersion());
  }
 catch (  ArtifactResolutionException e) {
    throw new MavenOperationException(e);
  }
}