Program: 29488
Project: 29488
Buggy source:
private HandlerProcessingResult processAnnotation(AnnotationInfo ainfo,WebBundleDescriptor webBundleDesc) throws AnnotationProcessorException {
  Class filterClass=(Class)ainfo.getAnnotatedElement();
  if (!javax.servlet.Filter.class.isAssignableFrom(filterClass)) {
    log(Level.SEVERE,ainfo,localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{filterClass.getName(),WebFilter.class.getName(),javax.servlet.Filter.class.getName()}));
    return getDefaultFailedResult();
  }
  WebFilter webFilterAn=(WebFilter)ainfo.getAnnotation();
  String filterName=webFilterAn.filterName();
  if (filterName == null || filterName.length() == 0) {
    filterName=filterClass.getName();
  }
  ServletFilterDescriptor servletFilterDesc=null;
  for (  ServletFilter sfDesc : webBundleDesc.getServletFilters()) {
    if (filterName.equals(sfDesc.getName())) {
      servletFilterDesc=(ServletFilterDescriptor)sfDesc;
      break;
    }
  }
  if (servletFilterDesc == null) {
    servletFilterDesc=new ServletFilterDescriptor();
    servletFilterDesc.setName(filterName);
    webBundleDesc.addServletFilter(servletFilterDesc);
  }
 else {
    String filterImpl=servletFilterDesc.getClassName();
    if (filterImpl != null && filterImpl.length() > 0 && !filterImpl.equals(filterClass.getName())) {
      log(Level.SEVERE,ainfo,localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{filterName,filterImpl,filterClass.getName(),WebFilter.class.getName()}));
      return getDefaultFailedResult();
    }
  }
  servletFilterDesc.setClassName(filterClass.getName());
  if (servletFilterDesc.getDescription() == null || servletFilterDesc.getDescription().length() == 0) {
    servletFilterDesc.setDescription(webFilterAn.description());
  }
  if (servletFilterDesc.hasSetDisplayName()) {
    servletFilterDesc.setDisplayName(webFilterAn.displayName());
  }
  if (servletFilterDesc.getInitializationParameters().size() == 0) {
    WebInitParam[] initParams=webFilterAn.initParams();
    if (initParams != null && initParams.length > 0) {
      for (      WebInitParam initParam : initParams) {
        servletFilterDesc.addInitializationParameter(new EnvironmentProperty(initParam.name(),initParam.value(),initParam.description()));
      }
    }
  }
  if (servletFilterDesc.getSmallIconUri() == null) {
    servletFilterDesc.setSmallIconUri(webFilterAn.smallIcon());
  }
  if (servletFilterDesc.getLargeIconUri() == null) {
    servletFilterDesc.setLargeIconUri(webFilterAn.largeIcon());
  }
  if (servletFilterDesc.isAsyncSupported() == null) {
    servletFilterDesc.setAsyncSupported(webFilterAn.asyncSupported());
  }
  ServletFilterMapping servletFilterMappingDesc=null;
  boolean hasUrlPattern=false;
  boolean hasServletName=false;
  for (  ServletFilterMapping sfm : webBundleDesc.getServletFilterMappings()) {
    if (filterName.equals(sfm.getName())) {
      servletFilterMappingDesc=sfm;
      hasUrlPattern=hasUrlPattern || (sfm.getURLPatterns().size() > 0);
      hasServletName=hasServletName || (sfm.getServletNames().size() > 0);
    }
  }
  if (servletFilterMappingDesc == null) {
    servletFilterMappingDesc=new ServletFilterMappingDescriptor();
    servletFilterMappingDesc.setName(filterName);
    webBundleDesc.addServletFilterMapping(servletFilterMappingDesc);
  }
  if (!hasUrlPattern) {
    String[] urlPatterns=webFilterAn.urlPatterns();
    if (urlPatterns == null || urlPatterns.length == 0) {
      urlPatterns=webFilterAn.value();
    }
    boolean validUrlPatterns=true;
    if (urlPatterns != null && urlPatterns.length > 0) {
      for (      String up : urlPatterns) {
        if (!URLPattern.isValid(up)) {
          validUrlPatterns=false;
          break;
        }
        servletFilterMappingDesc.addURLPattern(up);
      }
    }
    if (!validUrlPatterns) {
      String urlPatternString=(urlPatterns != null) ? Arrays.toString(urlPatterns) : "String_Node_Str";
      throw new IllegalArgumentException(localStrings.getLocalString("String_Node_Str","String_Node_Str",urlPatternString));
    }
  }
  if (!hasServletName) {
    String[] servletNames=webFilterAn.servletNames();
    if (servletNames != null && servletNames.length > 0) {
      for (      String sn : servletNames) {
        servletFilterMappingDesc.addServletName(sn);
      }
    }
  }
  if (servletFilterMappingDesc.getDispatchers().size() == 0) {
    DispatcherType[] dispatcherTypes=webFilterAn.dispatcherTypes();
    if (dispatcherTypes != null && dispatcherTypes.length > 0) {
      for (      DispatcherType dType : dispatcherTypes) {
        servletFilterMappingDesc.addDispatcher(dType.name());
      }
    }
  }
  return getDefaultProcessedResult();
}

Fixed version (ground truth):
private HandlerProcessingResult processAnnotation(AnnotationInfo ainfo,WebBundleDescriptor webBundleDesc) throws AnnotationProcessorException {
  Class filterClass=(Class)ainfo.getAnnotatedElement();
  if (!javax.servlet.Filter.class.isAssignableFrom(filterClass)) {
    log(Level.SEVERE,ainfo,localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{filterClass.getName(),WebFilter.class.getName(),javax.servlet.Filter.class.getName()}));
    return getDefaultFailedResult();
  }
  WebFilter webFilterAn=(WebFilter)ainfo.getAnnotation();
  String filterName=webFilterAn.filterName();
  if (filterName == null || filterName.length() == 0) {
    filterName=filterClass.getName();
  }
  ServletFilterDescriptor servletFilterDesc=null;
  for (  ServletFilter sfDesc : webBundleDesc.getServletFilters()) {
    if (filterName.equals(sfDesc.getName())) {
      servletFilterDesc=(ServletFilterDescriptor)sfDesc;
      break;
    }
  }
  if (servletFilterDesc == null) {
    servletFilterDesc=new ServletFilterDescriptor();
    servletFilterDesc.setName(filterName);
    webBundleDesc.addServletFilter(servletFilterDesc);
  }
 else {
    String filterImpl=servletFilterDesc.getClassName();
    if (filterImpl != null && filterImpl.length() > 0 && !filterImpl.equals(filterClass.getName())) {
      log(Level.SEVERE,ainfo,localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{filterName,filterImpl,filterClass.getName(),WebFilter.class.getName()}));
      return getDefaultFailedResult();
    }
  }
  servletFilterDesc.setClassName(filterClass.getName());
  if (servletFilterDesc.getDescription() == null || servletFilterDesc.getDescription().length() == 0) {
    servletFilterDesc.setDescription(webFilterAn.description());
  }
  if (servletFilterDesc.hasSetDisplayName()) {
    servletFilterDesc.setDisplayName(webFilterAn.displayName());
  }
  if (servletFilterDesc.getInitializationParameters().size() == 0) {
    WebInitParam[] initParams=webFilterAn.initParams();
    if (initParams != null && initParams.length > 0) {
      for (      WebInitParam initParam : initParams) {
        servletFilterDesc.addInitializationParameter(new EnvironmentProperty(initParam.name(),initParam.value(),initParam.description()));
      }
    }
  }
  if (servletFilterDesc.getSmallIconUri() == null) {
    servletFilterDesc.setSmallIconUri(webFilterAn.smallIcon());
  }
  if (servletFilterDesc.getLargeIconUri() == null) {
    servletFilterDesc.setLargeIconUri(webFilterAn.largeIcon());
  }
  if (servletFilterDesc.isAsyncSupported() == null) {
    servletFilterDesc.setAsyncSupported(webFilterAn.asyncSupported());
  }
  ServletFilterMapping servletFilterMappingDesc=null;
  boolean hasUrlPattern=false;
  boolean hasServletName=false;
  for (  ServletFilterMapping sfm : webBundleDesc.getServletFilterMappings()) {
    if (filterName.equals(sfm.getName())) {
      servletFilterMappingDesc=sfm;
      hasUrlPattern=hasUrlPattern || (sfm.getUrlPatterns().size() > 0);
      hasServletName=hasServletName || (sfm.getServletNames().size() > 0);
    }
  }
  if (servletFilterMappingDesc == null) {
    servletFilterMappingDesc=new ServletFilterMappingDescriptor();
    servletFilterMappingDesc.setName(filterName);
    webBundleDesc.addServletFilterMapping(servletFilterMappingDesc);
  }
  if (!hasUrlPattern) {
    String[] urlPatterns=webFilterAn.urlPatterns();
    if (urlPatterns == null || urlPatterns.length == 0) {
      urlPatterns=webFilterAn.value();
    }
    boolean validUrlPatterns=true;
    if (urlPatterns != null && urlPatterns.length > 0) {
      for (      String up : urlPatterns) {
        if (!URLPattern.isValid(up)) {
          validUrlPatterns=false;
          break;
        }
        servletFilterMappingDesc.addURLPattern(up);
      }
    }
    if (!validUrlPatterns) {
      String urlPatternString=(urlPatterns != null) ? Arrays.toString(urlPatterns) : "String_Node_Str";
      throw new IllegalArgumentException(localStrings.getLocalString("String_Node_Str","String_Node_Str",urlPatternString));
    }
  }
  if (!hasServletName) {
    String[] servletNames=webFilterAn.servletNames();
    if (servletNames != null && servletNames.length > 0) {
      for (      String sn : servletNames) {
        servletFilterMappingDesc.addServletName(sn);
      }
    }
  }
  if (servletFilterMappingDesc.getDispatchers().size() == 0) {
    DispatcherType[] dispatcherTypes=webFilterAn.dispatcherTypes();
    if (dispatcherTypes != null && dispatcherTypes.length > 0) {
      for (      DispatcherType dType : dispatcherTypes) {
        servletFilterMappingDesc.addDispatcher(dType.name());
      }
    }
  }
  return getDefaultProcessedResult();
}