Program: 29548
Project: 29548
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());
  for (  MimeMapping mimeMap : webBundleDescriptor.getMimeMappingsSet()) {
    addMimeMapping(mimeMap);
  }
  for (  ErrorPageDescriptor errPageDesc : webBundleDescriptor.getErrorPageDescriptorsSet()) {
    addErrorPageDescriptor(errPageDesc);
  }
  getAppListeners().addAll(webBundleDescriptor.getAppListeners());
  combineSecurityConstraints(getSecurityConstraintsSet(),webBundleDescriptor.getSecurityConstraintsSet());
  combineServletFilters(webBundleDescriptor);
  combineServletFilterMappings(webBundleDescriptor);
  if (getLocaleEncodingMappingListDescriptor() == null) {
    setLocaleEncodingMappingListDescriptor(webBundleDescriptor.getLocaleEncodingMappingListDescriptor());
  }
  if (webBundleDescriptor.getJspConfigDescriptor() != null) {
    JspConfigDescriptor jspConfigDesc=getJspConfigDescriptor();
    if (jspConfigDesc == null) {
      jspConfigDesc=new JspConfigDescriptor();
      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(otherIsDistributable);
    }
  }
  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());
  for (  MimeMapping mimeMap : webBundleDescriptor.getMimeMappingsSet()) {
    addMimeMapping(mimeMap);
  }
  for (  ErrorPageDescriptor errPageDesc : webBundleDescriptor.getErrorPageDescriptorsSet()) {
    addErrorPageDescriptor(errPageDesc);
  }
  getAppListeners().addAll(webBundleDescriptor.getAppListeners());
  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(otherIsDistributable);
    }
  }
  combinePostConstructDescriptors(webBundleDescriptor);
  combinePreDestroyDescriptors(webBundleDescriptor);
  addJndiNameEnvironment(webBundleDescriptor);
}