Program: 2503
Project: 2503
Buggy source:
/** 
 * Start the bundle.
 * @param context The context
 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
 */
public void start(final BundleContext context){
  final Commands commands=new Commands();
  Properties props=new Properties();
  commands.setParseCommand(new ParseCommand());
  context.registerService(Command.class.getName(),commands.getParseCommand(),props);
  commands.setValidateCommand(new ValidateCommand());
  context.registerService(Command.class.getName(),commands.getValidateCommand(),props);
  commands.setConformsCommand(new ConformsCommand());
  context.registerService(Command.class.getName(),commands.getConformsCommand(),props);
  commands.setProjectCommand(new ProjectCommand());
  context.registerService(Command.class.getName(),commands.getProjectCommand(),props);
  commands.setSimulateCommand(new SimulateCommand());
  context.registerService(Command.class.getName(),commands.getSimulateCommand(),props);
  ServiceListener[] sl=new ServiceListener[7];
  sl[0]=new ServiceListener(){
    public void serviceChanged(    ServiceEvent ev){
      ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
        ProtocolValidationManager vm=(ProtocolValidationManager)context.getService(sr);
      commands.setProtocolValidationManager(vm);
    break;
case ServiceEvent.UNREGISTERING:
  break;
}
}
}
;
sl[1]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
Journal journal=(Journal)context.getService(sr);
commands.setJournal(journal);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[2]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolParserManager pp=(ProtocolParserManager)context.getService(sr);
commands.setProtocolParserManager(pp);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[3]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolConformer conformer=(ProtocolConformer)context.getService(sr);
commands.setProtocolConformer(conformer);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[4]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolProjector projector=(ProtocolProjector)context.getService(sr);
commands.setProtocolProjector(projector);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[5]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolExportManager em=(ProtocolExportManager)context.getService(sr);
commands.setProtocolExportManager(em);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[6]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolMonitor pm=(ProtocolMonitor)context.getService(sr);
commands.setProtocolMonitor(pm);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
}

Fixed version (ground truth):
/** 
 * Start the bundle.
 * @param context The context
 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
 */
public void start(final BundleContext context){
  final Commands commands=new Commands();
  Properties props=new Properties();
  commands.setParseCommand(new ParseCommand());
  context.registerService(Command.class.getName(),commands.getParseCommand(),props);
  commands.setValidateCommand(new ValidateCommand());
  context.registerService(Command.class.getName(),commands.getValidateCommand(),props);
  commands.setConformsCommand(new ConformsCommand());
  context.registerService(Command.class.getName(),commands.getConformsCommand(),props);
  commands.setProjectCommand(new ProjectCommand());
  context.registerService(Command.class.getName(),commands.getProjectCommand(),props);
  commands.setSimulateCommand(new SimulateCommand());
  context.registerService(Command.class.getName(),commands.getSimulateCommand(),props);
  ServiceListener[] sl=new ServiceListener[7];
  sl[0]=new ServiceListener(){
    public void serviceChanged(    ServiceEvent ev){
      ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
        ProtocolValidationManager vm=(ProtocolValidationManager)context.getService(sr);
      commands.setProtocolValidationManager(vm);
    break;
case ServiceEvent.UNREGISTERING:
  break;
}
}
}
;
sl[1]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
Journal journal=(Journal)context.getService(sr);
commands.setJournal(journal);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[2]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolParserManager pp=(ProtocolParserManager)context.getService(sr);
commands.setProtocolParserManager(pp);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[3]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolConformer conformer=(ProtocolConformer)context.getService(sr);
commands.setProtocolConformer(conformer);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[4]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolProjector projector=(ProtocolProjector)context.getService(sr);
commands.setProtocolProjector(projector);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[5]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolExportManager em=(ProtocolExportManager)context.getService(sr);
commands.setProtocolExportManager(em);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
sl[6]=new ServiceListener(){
public void serviceChanged(ServiceEvent ev){
ServiceReference sr=ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
ProtocolMonitor pm=(ProtocolMonitor)context.getService(sr);
commands.setProtocolMonitor(pm);
break;
case ServiceEvent.UNREGISTERING:
break;
}
}
}
;
initCommands(context,commands,sl);
}