Program: 28361
Project: 28361
Buggy source:
protected synchronized void configureResource() throws LifecycleException {
  List<ApplicationParameter> appParams=context.findApplicationParameters();
  ContextParameter contextParam;
synchronized (appParams) {
    Iterator<ApplicationParameter> i=appParams.iterator();
    while (i.hasNext()) {
      ApplicationParameter appParam=i.next();
      contextParam=new EnvironmentProperty(appParam.getName(),appParam.getValue(),appParam.getDescription());
      webBundleDescriptor.addContextParameter(contextParam);
    }
  }
  ContextEnvironment[] envs=context.findEnvironments();
  EnvironmentProperty envEntry;
  for (int i=0; i < envs.length; i++) {
    envEntry=new EnvironmentProperty(envs[i].getName(),envs[i].getValue(),envs[i].getDescription(),envs[i].getType());
    if (envs[i].getValue() != null) {
      envEntry.setValue(envs[i].getValue());
    }
    webBundleDescriptor.addEnvironmentProperty(envEntry);
    envProps.add(envEntry);
  }
  ContextResource[] resources=context.findResources();
  ResourceReferenceDescriptor resourceReference;
  Set<ResourceReferenceDescriptor> rrs=webBundleDescriptor.getResourceReferenceDescriptors();
  ResourcePrincipal rp;
  for (int i=0; i < resources.length; i++) {
    resourceReference=new ResourceReferenceDescriptor(resources[i].getName(),resources[i].getDescription(),resources[i].getType());
    resourceReference.setJndiName(resources[i].getName());
    if (rrs != null) {
      for (      ResourceReferenceDescriptor rr : rrs) {
        if (resources[i].getName().equals(rr.getName())) {
          resourceReference.setJndiName(rr.getJndiName());
          rp=rr.getResourcePrincipal();
          if (rp != null) {
            resourceReference.setResourcePrincipal(new ResourcePrincipal(rp.getName(),rp.getPassword()));
          }
        }
      }
    }
    resourceReference.setAuthorization(resources[i].getAuth());
    webBundleDescriptor.addResourceReferenceDescriptor(resourceReference);
    resRefs.add(resourceReference);
  }
}

Fixed version (ground truth):
protected synchronized void configureResource() throws LifecycleException {
  List<ApplicationParameter> appParams=context.findApplicationParameters();
  ContextParameter contextParam;
synchronized (appParams) {
    Iterator<ApplicationParameter> i=appParams.iterator();
    while (i.hasNext()) {
      ApplicationParameter appParam=i.next();
      contextParam=new EnvironmentProperty(appParam.getName(),appParam.getValue(),appParam.getDescription());
      webBundleDescriptor.addContextParameter(contextParam);
    }
  }
  ContextEnvironment[] envs=context.findEnvironments();
  EnvironmentProperty envEntry;
  for (int i=0; i < envs.length; i++) {
    envEntry=new EnvironmentProperty(envs[i].getName(),envs[i].getValue(),envs[i].getDescription(),envs[i].getType());
    if (envs[i].getValue() != null) {
      envEntry.setValue(envs[i].getValue());
    }
    webBundleDescriptor.addEnvironmentProperty(envEntry);
    envProps.add(envEntry);
  }
  ContextResource[] resources=context.findResources();
  ResourceReferenceDescriptor resourceReference;
  Set<ResourceReferenceDescriptor> rrs=webBundleDescriptor.getResourceReferenceDescriptors();
  ResourcePrincipal rp;
  for (int i=0; i < resources.length; i++) {
    resourceReference=new ResourceReferenceDescriptor(resources[i].getName(),resources[i].getDescription(),resources[i].getType());
    resourceReference.setJndiName(resources[i].getName());
    for (    ResourceReferenceDescriptor rr : rrs) {
      if (resources[i].getName().equals(rr.getName())) {
        resourceReference.setJndiName(rr.getJndiName());
        rp=rr.getResourcePrincipal();
        if (rp != null) {
          resourceReference.setResourcePrincipal(new ResourcePrincipal(rp.getName(),rp.getPassword()));
        }
      }
    }
    resourceReference.setAuthorization(resources[i].getAuth());
    webBundleDescriptor.addResourceReferenceDescriptor(resourceReference);
    resRefs.add(resourceReference);
  }
}