Program: 28171
Project: 28171
Buggy source:
/** 
 * This method combines all except welcome file set for two webBundleDescriptors.
 */
private void addCommonWebBundleDescriptor(WebBundleDescriptor wbd){
  super.addBundleDescriptor(wbd);
  WebBundleDescriptorImpl webBundleDescriptor=(WebBundleDescriptorImpl)wbd;
  for (  WebComponentDescriptor webComponentDesc : webBundleDescriptor.getWebComponentDescriptors()) {
    WebComponentDescriptorImpl webComponentDescriptor=new WebComponentDescriptorImpl(webComponentDesc);
    webComponentDescriptor.setWebBundleDescriptor(null);
    List<String> removeUrlPatterns=null;
    for (    String urlPattern : webComponentDescriptor.getUrlPatternsSet()) {
      String servletName=null;
      if (urlPattern2ServletName != null) {
        servletName=urlPattern2ServletName.get(urlPattern);
      }
      if (servletName != null && (!servletName.equals(webComponentDescriptor.getCanonicalName()))) {
        if (removeUrlPatterns == null) {
          removeUrlPatterns=new ArrayList<String>();
        }
        removeUrlPatterns.add(urlPattern);
      }
    }
    if (removeUrlPatterns != null) {
      webComponentDescriptor.getUrlPatternsSet().removeAll(removeUrlPatterns);
    }
    addWebComponentDescriptor(webComponentDescriptor);
  }
  getContextParametersSet().addAll(webBundleDescriptor.getContextParametersSet());
  if (conflictedMimeMappingExtensions == null) {
    conflictedMimeMappingExtensions=webBundleDescriptor.getConflictedMimeMappingExtensions();
  }
 else {
    conflictedMimeMappingExtensions.addAll(webBundleDescriptor.getConflictedMimeMappingExtensions());
  }
  combineMimeMappings(webBundleDescriptor.getMimeMappingsSet());
  for (  ErrorPageDescriptor errPageDesc : webBundleDescriptor.getErrorPageDescriptorsSet()) {
    addErrorPageDescriptor(errPageDesc);
  }
  getAppListeners().addAll(webBundleDescriptor.getAppListeners());
  if (webBundleDescriptor.isDenyUncoveredHttpMethods()) {
    setDenyUncoveredHttpMethods(true);
  }
  combineSecurityConstraints(getSecurityConstraintsSet(),webBundleDescriptor.getSecurityConstraintsSet());
  combineServletFilters(webBundleDescriptor);
  combineServletFilterMappings(webBundleDescriptor);
  if (getLocaleEncodingMappingListDescriptor() == null) {
    setLocaleEncodingMappingListDescriptor(webBundleDescriptor.getLocaleEncodingMappingListDescriptor());
  }
  if (webBundleDescriptor.getJspConfigDescriptor() != null) {
    JspConfigDescriptorImpl jspConfigDesc=getJspConfigDescriptor();
    if (jspConfigDesc == null) {
      jspConfigDesc=new JspConfigDescriptorImpl();
      setJspConfigDescriptor(jspConfigDesc);
    }
    jspConfigDescriptor.add(webBundleDescriptor.getJspConfigDescriptor());
  }
  WebServicesDescriptor thisWebServices=this.getWebServices();
  WebServicesDescriptor otherWebServices=webBundleDescriptor.getWebServices();
  for (  WebService ws : otherWebServices.getWebServices()) {
    thisWebServices.addWebService(new WebService(ws));
  }
  if (getSessionConfig() == null) {
    setSessionConfig(webBundleDescriptor.getSessionConfig());
  }
  combineLoginConfiguration(webBundleDescriptor);
  Boolean otherIsDistributable=webBundleDescriptor.isDistributable();
  if (otherIsDistributable != null) {
    if (isDistributable != null) {
      setDistributable(isDistributable && otherIsDistributable);
    }
 else {
      setDistributable(false);
    }
  }
  combinePostConstructDescriptors(webBundleDescriptor);
  combinePreDestroyDescriptors(webBundleDescriptor);
  addJndiNameEnvironment(webBundleDescriptor);
}

Fixed version (ground truth):
/** 
 * This method combines all except welcome file set for two webBundleDescriptors.
 */
private void addCommonWebBundleDescriptor(WebBundleDescriptor wbd){
  super.addBundleDescriptor(wbd);
  WebBundleDescriptorImpl webBundleDescriptor=(WebBundleDescriptorImpl)wbd;
  for (  WebComponentDescriptor webComponentDesc : webBundleDescriptor.getWebComponentDescriptors()) {
    WebComponentDescriptorImpl webComponentDescriptor=new WebComponentDescriptorImpl(webComponentDesc);
    webComponentDescriptor.setWebBundleDescriptor(null);
    List<String> removeUrlPatterns=null;
    for (    String urlPattern : webComponentDescriptor.getUrlPatternsSet()) {
      String servletName=null;
      if (urlPattern2ServletName != null) {
        servletName=urlPattern2ServletName.get(urlPattern);
      }
      if (servletName != null && (!servletName.equals(webComponentDescriptor.getCanonicalName()))) {
        if (removeUrlPatterns == null) {
          removeUrlPatterns=new ArrayList<String>();
        }
        removeUrlPatterns.add(urlPattern);
      }
    }
    if (removeUrlPatterns != null) {
      webComponentDescriptor.getUrlPatternsSet().removeAll(removeUrlPatterns);
    }
    addWebComponentDescriptor(webComponentDescriptor);
  }
  getContextParametersSet().addAll(webBundleDescriptor.getContextParametersSet());
  if (conflictedMimeMappingExtensions == null) {
    conflictedMimeMappingExtensions=webBundleDescriptor.getConflictedMimeMappingExtensions();
  }
 else {
    conflictedMimeMappingExtensions.addAll(webBundleDescriptor.getConflictedMimeMappingExtensions());
  }
  combineMimeMappings(webBundleDescriptor.getMimeMappingsSet());
  for (  ErrorPageDescriptor errPageDesc : webBundleDescriptor.getErrorPageDescriptorsSet()) {
    addErrorPageDescriptor(errPageDesc);
  }
  getAppListeners().addAll(webBundleDescriptor.getAppListeners());
  if (webBundleDescriptor.isDenyUncoveredHttpMethods()) {
    setDenyUncoveredHttpMethods(true);
  }
  combineSecurityConstraints(getSecurityConstraintsSet(),webBundleDescriptor.getSecurityConstraintsSet());
  combineServletFilters(webBundleDescriptor);
  combineServletFilterMappings(webBundleDescriptor);
  if (getLocaleEncodingMappingListDescriptor() == null) {
    setLocaleEncodingMappingListDescriptor(webBundleDescriptor.getLocaleEncodingMappingListDescriptor());
  }
  if (webBundleDescriptor.getJspConfigDescriptor() != null) {
    JspConfigDescriptorImpl jspConfigDesc=getJspConfigDescriptor();
    if (jspConfigDesc == null) {
      jspConfigDesc=new JspConfigDescriptorImpl();
      setJspConfigDescriptor(jspConfigDesc);
    }
    jspConfigDescriptor.add(webBundleDescriptor.getJspConfigDescriptor());
  }
  WebServicesDescriptor thisWebServices=this.getWebServices();
  WebServicesDescriptor otherWebServices=webBundleDescriptor.getWebServices();
  for (  WebService ws : otherWebServices.getWebServices()) {
    thisWebServices.addWebService(new WebService(ws));
  }
  if (getSessionConfig() == null) {
    setSessionConfig(webBundleDescriptor.getSessionConfig());
  }
  combineLoginConfiguration(webBundleDescriptor);
  Boolean otherIsDistributable=webBundleDescriptor.isDistributable();
  if (otherIsDistributable != null && webBundleDescriptor.isExists()) {
    if (isDistributable != null) {
      setDistributable(isDistributable && otherIsDistributable);
    }
 else {
      setDistributable(otherIsDistributable);
    }
  }
  combinePostConstructDescriptors(webBundleDescriptor);
  combinePreDestroyDescriptors(webBundleDescriptor);
  addJndiNameEnvironment(webBundleDescriptor);
}