Program: 5602
Project: 5602
Buggy source:
public void setupCommands(final ComponentRegistry registry,CommandHandler handler){
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    private PrintStream out;
    private Pattern pattern;
    private boolean isInverted=false;
    public int executeCommand(    CommandContext context){
      int index=0;
      int flags=0;
      while (index + 1 < context.getArgumentCount()) {
        if ("String_Node_Str".equals(context.getArgument(index))) {
          flags|=Pattern.CASE_INSENSITIVE;
        }
 else         if ("String_Node_Str".equals(context.getArgument(index))) {
          isInverted=true;
        }
 else {
          context.err.println("String_Node_Str" + context.getArgument(index));
          return 1;
        }
        index++;
      }
      out=context.out;
      pattern=Pattern.compile(context.getArgument(index),flags);
      return 0;
    }
    public void lineRead(    String line){
      boolean isMatch=pattern.matcher(line).find();
      if (isMatch ^ isInverted) {
        out.println(line);
      }
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    private PrintStream out;
    private MSP430 cpu;
    long startTime;
    public int executeCommand(    CommandContext context){
      cpu=(MSP430)registry.getComponent(MSP430.class);
      if (cpu == null) {
        context.err.println("String_Node_Str");
        return 1;
      }
      out=context.out;
      startTime=System.currentTimeMillis() - (long)cpu.getTimeMillis();
      return 0;
    }
    public void lineRead(    String line){
      out.println(Long.toString(startTime + (long)cpu.getTimeMillis()) + ' ' + line);
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      MSP430 cpu=(MSP430)registry.getComponent(MSP430.class);
      if (cpu == null) {
        context.err.println("String_Node_Str");
        return 1;
      }
 else       if (context.getArgumentCount() == 0) {
        long rate=cpu.getSleepRate();
        double d=rate / 25000.0;
        context.out.println("String_Node_Str" + (((int)(d * 100 + 0.5)) / 100.0));
      }
 else {
        double d=context.getArgumentAsDouble(0);
        if (d > 0.0) {
          long rate=(long)(25000 * d);
          cpu.setSleepRate(rate);
        }
 else {
          context.err.println("String_Node_Str");
          return 1;
        }
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      StringBuilder sb=new StringBuilder();
      for (int i=0, n=context.getArgumentCount(); i < n; i++) {
        if (i > 0)         sb.append(' ');
        sb.append(context.getArgument(i));
      }
      context.out.println(sb.toString());
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      boolean verbose=false;
      if (context.getArgumentCount() > 1) {
        verbose="String_Node_Str".equals(context.getArgument(0));
      }
      File fp=new File(context.getArgument(context.getArgumentCount() - 1));
      if (!fp.canRead()) {
        context.err.println("String_Node_Str" + context.getArgument(0) + "String_Node_Str");
        return 1;
      }
      try {
        FileInputStream infs=new FileInputStream(fp);
        BufferedReader input=new BufferedReader(new InputStreamReader(infs));
        try {
          String line;
          while ((line=input.readLine()) != null) {
            if (verbose)             context.out.println(line);
            context.executeCommand(line);
          }
        }
  finally {
          input.close();
        }
      }
 catch (      IOException e) {
        e.printStackTrace(context.err);
        return 1;
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
    private MSP430 cpu;
    private int period=1;
    private int count=0;
    private int maxCount=-1;
    private String commandLine;
    private boolean isRunning=true;
    public int executeCommand(    final CommandContext context){
      int index=0;
      do {
        String a=context.getArgument(index);
        if (a.startsWith("String_Node_Str")) {
          if (a.equals("String_Node_Str")) {
            period=context.getArgumentAsInt(index + 1);
            index+=2;
          }
 else           if (a.equals("String_Node_Str")) {
            maxCount=context.getArgumentAsInt(index + 1);
            index+=2;
          }
 else {
            context.err.println("String_Node_Str" + a);
            return 1;
          }
        }
 else {
          break;
        }
      }
 while (true);
      if (index + 1 < context.getArgumentCount()) {
        context.err.println("String_Node_Str");
        return 1;
      }
      commandLine=context.getArgument(index);
      cpu=(MSP430)registry.getComponent(MSP430.class);
      if (cpu == null) {
        context.err.println("String_Node_Str");
        return 1;
      }
      cpu.scheduleTimeEventMillis(new TimeEvent(0){
        @Override public void execute(        long t){
          if (isRunning) {
            count++;
            context.executeCommand(commandLine);
            if ((maxCount <= 0) || (count < maxCount)) {
              cpu.scheduleTimeEventMillis(this,period * 1000d);
            }
 else {
              stopCommand(context);
            }
          }
        }
      }
,period * 1000d);
      return 0;
    }
    public void stopCommand(    CommandContext context){
      isRunning=false;
      context.err.println("String_Node_Str" + commandLine + ']');
      context.exit(0);
    }
  }
);
  handler.registerCommand("String_Node_Str",new ExecCommand());
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    String command=null;
    CommandContext context;
    public int executeCommand(    CommandContext context){
      StringBuilder sb=new StringBuilder();
      for (int i=0, n=context.getArgumentCount(); i < n; i++) {
        if (i > 0)         sb.append(' ');
        sb.append(context.getArgument(i));
      }
      command=sb.toString();
      this.context=context;
      return 0;
    }
    public void lineRead(    String line){
      context.executeCommand(command);
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    @Override public int executeCommand(    CommandContext context){
      String className=context.getArgument(0);
      String name=className;
      if (context.getArgumentCount() > 1) {
        name=context.getArgument(1);
      }
      if (registry.getComponent(name) != null) {
        context.err.println("String_Node_Str" + name + "String_Node_Str");
        return 1;
      }
      Class pluginClass=null;
      PluginRepository plugins=(PluginRepository)registry.getComponent("String_Node_Str");
      try {
        try {
          pluginClass=plugins != null ? plugins.loadClass(className) : Class.forName(className);
        }
 catch (        ClassNotFoundException e) {
          String newClassName="String_Node_Str" + className;
          pluginClass=plugins != null ? plugins.loadClass(newClassName) : Class.forName(newClassName);
        }
        Object component=pluginClass.newInstance();
        registry.registerComponent(name,component);
        return 0;
      }
 catch (      Exception e1) {
        e1.printStackTrace(context.err);
      }
      return 1;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    @Override public int executeCommand(    CommandContext context){
      if (context.getArgumentCount() == 0) {
        ServiceComponent[] sc=(ServiceComponent[])registry.getAllComponents(ServiceComponent.class);
        for (int i=0; i < sc.length; i++) {
          context.out.printf("String_Node_Str",sc[i].getName(),sc[i].getStatus());
        }
      }
 else       if (context.getArgumentCount() == 1) {
        String name=context.getArgument(0);
        ServiceComponent sc=getServiceForName(registry,name);
        if (sc != null) {
          context.out.printf("String_Node_Str",sc.getName(),sc.getStatus());
        }
 else {
          context.out.println("String_Node_Str" + name);
        }
      }
 else {
        String name=context.getArgument(0);
        String operation=context.getArgument(1);
        if ("String_Node_Str".equals(operation)) {
          ServiceComponent sc=getServiceForName(registry,name);
          if (sc != null) {
            sc.start();
            context.out.println("String_Node_Str" + sc.getName() + "String_Node_Str");
          }
 else {
            context.out.println("String_Node_Str" + name);
          }
        }
 else         if ("String_Node_Str".equals(operation)) {
          ServiceComponent sc=getServiceForName(registry,name);
          if (sc != null) {
            sc.start();
            context.out.println("String_Node_Str" + sc.getName() + "String_Node_Str");
          }
 else {
            context.out.println("String_Node_Str" + name);
          }
        }
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    CommandContext context;
    RFListener listener;
    final MSP430 cpu=(MSP430)registry.getComponent(MSP430.class);
    public int executeCommand(    CommandContext ctx){
      this.context=ctx;
      String inout=context.getArgument(0);
      Chip chip=cpu.getChip(context.getArgument(1));
      if ("String_Node_Str".equals(inout)) {
        if (chip instanceof RFSource) {
          ((RFSource)chip).setRFListener(new RFListener(){
            public void receivedByte(            byte data){
              context.out.println("String_Node_Str" + Utils.hex8(data));
            }
          }
);
        }
      }
 else       if ("String_Node_Str".equals(inout)) {
        listener=(RFListener)chip;
      }
 else {
        context.err.println("String_Node_Str" + inout);
      }
      return 0;
    }
    public void lineRead(    String line){
      if (listener != null) {
        byte[] data=Utils.hexconv(line);
        context.out.println("String_Node_Str" + line);
        for (int i=0; i < data.length; i++) {
          listener.receivedByte(data[i]);
        }
      }
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      ArgumentManager config=(ArgumentManager)registry.getComponent("String_Node_Str");
      context.out.println("String_Node_Str");
      context.out.println("String_Node_Str" + MSP430Constants.VERSION);
      context.out.println("String_Node_Str" + System.getProperty("String_Node_Str") + "String_Node_Str"+ System.getProperty("String_Node_Str"));
      context.out.println("String_Node_Str" + config.getProperty("String_Node_Str"));
      context.out.println("String_Node_Str" + config.getProperty("String_Node_Str"));
      context.out.println();
      if (context.getOption("String_Node_Str")) {
        context.out.println("String_Node_Str");
        registry.printRegistry(context.out);
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      System.exit(0);
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      System.exit(0);
      return 0;
    }
  }
);
}

Fixed version (ground truth):
public void setupCommands(final ComponentRegistry registry,CommandHandler handler){
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    private PrintStream out;
    private Pattern pattern;
    private boolean isInverted=false;
    public int executeCommand(    CommandContext context){
      int index=0;
      int flags=0;
      while (index + 1 < context.getArgumentCount()) {
        if ("String_Node_Str".equals(context.getArgument(index))) {
          flags|=Pattern.CASE_INSENSITIVE;
        }
 else         if ("String_Node_Str".equals(context.getArgument(index))) {
          isInverted=true;
        }
 else {
          context.err.println("String_Node_Str" + context.getArgument(index));
          return 1;
        }
        index++;
      }
      out=context.out;
      pattern=Pattern.compile(context.getArgument(index),flags);
      return 0;
    }
    public void lineRead(    String line){
      boolean isMatch=pattern.matcher(line).find();
      if (isMatch ^ isInverted) {
        out.println(line);
      }
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    private PrintStream out;
    private MSP430 cpu;
    long startTime;
    public int executeCommand(    CommandContext context){
      cpu=(MSP430)registry.getComponent(MSP430.class);
      if (cpu == null) {
        context.err.println("String_Node_Str");
        return 1;
      }
      out=context.out;
      startTime=System.currentTimeMillis() - (long)cpu.getTimeMillis();
      return 0;
    }
    public void lineRead(    String line){
      out.println(Long.toString(startTime + (long)cpu.getTimeMillis()) + ' ' + line);
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      MSP430 cpu=(MSP430)registry.getComponent(MSP430.class);
      if (cpu == null) {
        context.err.println("String_Node_Str");
        return 1;
      }
 else       if (context.getArgumentCount() == 0) {
        long rate=cpu.getSleepRate();
        double d=rate / 25000.0;
        context.out.println("String_Node_Str" + (((int)(d * 100 + 0.5)) / 100.0));
      }
 else {
        double d=context.getArgumentAsDouble(0);
        if (d > 0.0) {
          long rate=(long)(25000 * d);
          cpu.setSleepRate(rate);
        }
 else {
          context.err.println("String_Node_Str");
          return 1;
        }
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      StringBuilder sb=new StringBuilder();
      for (int i=0, n=context.getArgumentCount(); i < n; i++) {
        if (i > 0)         sb.append(' ');
        sb.append(context.getArgument(i));
      }
      context.out.println(sb.toString());
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      boolean verbose=false;
      if (context.getArgumentCount() > 1) {
        verbose="String_Node_Str".equals(context.getArgument(0));
      }
      File fp=new File(context.getArgument(context.getArgumentCount() - 1));
      if (!fp.canRead()) {
        context.err.println("String_Node_Str" + context.getArgument(0) + "String_Node_Str");
        return 1;
      }
      try {
        FileInputStream infs=new FileInputStream(fp);
        BufferedReader input=new BufferedReader(new InputStreamReader(infs));
        try {
          String line;
          while ((line=input.readLine()) != null) {
            if (verbose)             context.out.println(line);
            context.executeCommand(line);
          }
        }
  finally {
          input.close();
        }
      }
 catch (      IOException e) {
        e.printStackTrace(context.err);
        return 1;
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicAsyncCommand("String_Node_Str","String_Node_Str"){
    private MSP430 cpu;
    private int period=1;
    private int count=0;
    private int maxCount=-1;
    private String commandLine;
    private boolean isRunning=true;
    public int executeCommand(    final CommandContext context){
      int index=0;
      do {
        String a=context.getArgument(index);
        if (a.startsWith("String_Node_Str")) {
          if (a.equals("String_Node_Str")) {
            period=context.getArgumentAsInt(index + 1);
            index+=2;
          }
 else           if (a.equals("String_Node_Str")) {
            maxCount=context.getArgumentAsInt(index + 1);
            index+=2;
          }
 else {
            context.err.println("String_Node_Str" + a);
            return 1;
          }
        }
 else {
          break;
        }
      }
 while (true);
      if (index + 1 < context.getArgumentCount()) {
        context.err.println("String_Node_Str");
        return 1;
      }
      commandLine=context.getArgument(index);
      cpu=(MSP430)registry.getComponent(MSP430.class);
      if (cpu == null) {
        context.err.println("String_Node_Str");
        return 1;
      }
      cpu.scheduleTimeEventMillis(new TimeEvent(0){
        @Override public void execute(        long t){
          if (isRunning) {
            count++;
            context.executeCommand(commandLine);
            if ((maxCount <= 0) || (count < maxCount)) {
              cpu.scheduleTimeEventMillis(this,period * 1000d);
            }
 else {
              stopCommand(context);
            }
          }
        }
      }
,period * 1000d);
      return 0;
    }
    public void stopCommand(    CommandContext context){
      isRunning=false;
      context.err.println("String_Node_Str" + commandLine + ']');
      context.exit(0);
    }
  }
);
  handler.registerCommand("String_Node_Str",new ExecCommand());
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    String command=null;
    CommandContext context;
    public int executeCommand(    CommandContext context){
      StringBuilder sb=new StringBuilder();
      for (int i=0, n=context.getArgumentCount(); i < n; i++) {
        if (i > 0)         sb.append(' ');
        sb.append(context.getArgument(i));
      }
      command=sb.toString();
      this.context=context;
      return 0;
    }
    public void lineRead(    String line){
      context.executeCommand(command);
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    @Override public int executeCommand(    CommandContext context){
      String className=context.getArgument(0);
      String name=className;
      if (context.getArgumentCount() > 1) {
        name=context.getArgument(1);
      }
      if (registry.getComponent(name) != null) {
        context.err.println("String_Node_Str" + name + "String_Node_Str");
        return 1;
      }
      Class pluginClass=null;
      PluginRepository plugins=(PluginRepository)registry.getComponent("String_Node_Str");
      try {
        try {
          pluginClass=plugins != null ? plugins.loadClass(className) : Class.forName(className);
        }
 catch (        ClassNotFoundException e) {
          String newClassName="String_Node_Str" + className;
          pluginClass=plugins != null ? plugins.loadClass(newClassName) : Class.forName(newClassName);
        }
        Object component=pluginClass.newInstance();
        registry.registerComponent(name,component);
        return 0;
      }
 catch (      Exception e1) {
        e1.printStackTrace(context.err);
      }
      return 1;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    @Override public int executeCommand(    CommandContext context){
      if (context.getArgumentCount() == 0) {
        ServiceComponent[] sc=(ServiceComponent[])registry.getAllComponents(ServiceComponent.class);
        for (int i=0; i < sc.length; i++) {
          context.out.printf("String_Node_Str",sc[i].getName(),sc[i].getStatus());
        }
      }
 else       if (context.getArgumentCount() == 1) {
        String name=context.getArgument(0);
        ServiceComponent sc=getServiceForName(registry,name);
        if (sc != null) {
          context.out.printf("String_Node_Str",sc.getName(),sc.getStatus());
        }
 else {
          context.out.println("String_Node_Str" + name);
        }
      }
 else {
        String name=context.getArgument(0);
        String operation=context.getArgument(1);
        if ("String_Node_Str".equals(operation)) {
          ServiceComponent sc=getServiceForName(registry,name);
          if (sc != null) {
            sc.start();
            context.out.println("String_Node_Str" + sc.getName() + "String_Node_Str");
          }
 else {
            context.out.println("String_Node_Str" + name);
          }
        }
 else         if ("String_Node_Str".equals(operation)) {
          ServiceComponent sc=getServiceForName(registry,name);
          if (sc != null) {
            sc.stop();
            context.out.println("String_Node_Str" + sc.getName() + "String_Node_Str");
          }
 else {
            context.out.println("String_Node_Str" + name);
          }
        }
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicLineCommand("String_Node_Str","String_Node_Str"){
    CommandContext context;
    RFListener listener;
    final MSP430 cpu=(MSP430)registry.getComponent(MSP430.class);
    public int executeCommand(    CommandContext ctx){
      this.context=ctx;
      String inout=context.getArgument(0);
      Chip chip=cpu.getChip(context.getArgument(1));
      if ("String_Node_Str".equals(inout)) {
        if (chip instanceof RFSource) {
          ((RFSource)chip).setRFListener(new RFListener(){
            public void receivedByte(            byte data){
              context.out.println("String_Node_Str" + Utils.hex8(data));
            }
          }
);
        }
      }
 else       if ("String_Node_Str".equals(inout)) {
        listener=(RFListener)chip;
      }
 else {
        context.err.println("String_Node_Str" + inout);
      }
      return 0;
    }
    public void lineRead(    String line){
      if (listener != null) {
        byte[] data=Utils.hexconv(line);
        context.out.println("String_Node_Str" + line);
        for (int i=0; i < data.length; i++) {
          listener.receivedByte(data[i]);
        }
      }
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      ArgumentManager config=(ArgumentManager)registry.getComponent("String_Node_Str");
      context.out.println("String_Node_Str");
      context.out.println("String_Node_Str" + MSP430Constants.VERSION);
      context.out.println("String_Node_Str" + System.getProperty("String_Node_Str") + "String_Node_Str"+ System.getProperty("String_Node_Str"));
      context.out.println("String_Node_Str" + config.getProperty("String_Node_Str"));
      context.out.println("String_Node_Str" + config.getProperty("String_Node_Str"));
      context.out.println();
      if (context.getOption("String_Node_Str")) {
        context.out.println("String_Node_Str");
        registry.printRegistry(context.out);
      }
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      System.exit(0);
      return 0;
    }
  }
);
  handler.registerCommand("String_Node_Str",new BasicCommand("String_Node_Str","String_Node_Str"){
    public int executeCommand(    CommandContext context){
      System.exit(0);
      return 0;
    }
  }
);
}