Program: 34754
Project: 34754
Buggy source:
public OpenAPI read(Class<?> cls,String parentPath){
  List<org.eclipse.microprofile.openapi.annotations.security.SecurityScheme> apiSecurityScheme=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.security.SecurityScheme.class);
  List<org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement> apiSecurityRequirements=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement.class);
  List<org.eclipse.microprofile.openapi.annotations.servers.Server> apiServers=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.servers.Server.class);
  List<org.eclipse.microprofile.openapi.annotations.callbacks.Callback> apiCallbacks=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.callbacks.Callback.class);
  ExternalDocumentation apiExternalDocs=ReflectionUtils.getAnnotation(cls,ExternalDocumentation.class);
  org.eclipse.microprofile.openapi.annotations.tags.Tag[] apiTags=ReflectionUtils.getRepeatableAnnotationsArray(cls,org.eclipse.microprofile.openapi.annotations.tags.Tag.class);
  org.eclipse.microprofile.openapi.annotations.tags.Tags tagsAnnotation=ReflectionUtils.getAnnotation(cls,org.eclipse.microprofile.openapi.annotations.tags.Tags.class);
  javax.ws.rs.Consumes classConsumes=ReflectionUtils.getAnnotation(cls,javax.ws.rs.Consumes.class);
  javax.ws.rs.Produces classProduces=ReflectionUtils.getAnnotation(cls,javax.ws.rs.Produces.class);
  if (apiSecurityScheme != null) {
    for (    org.eclipse.microprofile.openapi.annotations.security.SecurityScheme securitySchemeAnnotation : apiSecurityScheme) {
      Optional<SecurityScheme> securityScheme=SecurityParser.getSecurityScheme(securitySchemeAnnotation);
      if (securityScheme.isPresent()) {
        Map<String,SecurityScheme> securitySchemeMap=new HashMap<>();
        if (StringUtils.isNotBlank(((SecuritySchemeImpl)securityScheme.get()).getSchemeName())) {
          securitySchemeMap.put(((SecuritySchemeImpl)securityScheme.get()).getSchemeName(),securityScheme.get());
          if (components.getSecuritySchemes() != null && components.getSecuritySchemes().size() != 0) {
            components.getSecuritySchemes().putAll(securitySchemeMap);
          }
 else {
            components.setSecuritySchemes(securitySchemeMap);
          }
        }
      }
    }
  }
  List<SecurityRequirement> classSecurityRequirements=new ArrayList<>();
  if (apiSecurityRequirements != null) {
    Optional<List<SecurityRequirement>> requirementsObject=SecurityParser.getSecurityRequirements(apiSecurityRequirements.toArray(new org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement[apiSecurityRequirements.size()]));
    if (requirementsObject.isPresent()) {
      classSecurityRequirements=requirementsObject.get();
    }
  }
  List<org.eclipse.microprofile.openapi.models.servers.Server> classServers=new ArrayList<>();
  if (apiServers != null) {
    Optional<List<org.eclipse.microprofile.openapi.models.servers.Server>> serversObject=AnnotationsUtils.getServers(apiServers.toArray(new org.eclipse.microprofile.openapi.annotations.servers.Server[apiServers.size()]));
    if (serversObject.isPresent()) {
      classServers=serversObject.get();
    }
  }
  Map<String,Callback> classCallbacks=null;
  if (apiCallbacks != null) {
    Map<String,Callback> callbacks=new LinkedHashMap<>();
    for (    org.eclipse.microprofile.openapi.annotations.callbacks.Callback classCallback : apiCallbacks) {
      Map<String,Callback> currentCallbacks=getCallbacks(classCallback);
      callbacks.putAll(currentCallbacks);
    }
    if (callbacks.size() > 0) {
      classCallbacks=callbacks;
    }
  }
  final Set<String> classTags=new LinkedHashSet<>();
  if (apiTags != null) {
    AnnotationsUtils.getTags(apiTags,false).ifPresent(tags -> tags.stream().map(t -> t.getName()).forEach(t -> classTags.add(t)));
  }
  if (tagsAnnotation != null && tagsAnnotation.refs() != null) {
    classTags.addAll(Stream.of(tagsAnnotation.refs()).filter(StringUtils::isNotBlank).collect(Collectors.toList()));
  }
  Optional<org.eclipse.microprofile.openapi.models.ExternalDocumentation> classExternalDocumentation=AnnotationsUtils.getExternalDocumentation(apiExternalDocs);
  final javax.ws.rs.Path apiPath=ReflectionUtils.getAnnotation(cls,javax.ws.rs.Path.class);
  JavaType classType=TypeFactory.defaultInstance().constructType(cls);
  BeanDescription bd=Json.mapper().getSerializationConfig().introspect(classType);
  final List<Parameter> globalParameters=new ArrayList<>();
  globalParameters.addAll(ReaderUtils.collectConstructorParameters(cls,components,classConsumes));
  globalParameters.addAll(ReaderUtils.collectFieldParameters(cls,components,classConsumes));
  Method methods[]=cls.getMethods();
  for (  Method method : methods) {
    if (isOperationHidden(method)) {
      continue;
    }
    AnnotatedMethod annotatedMethod=bd.findMethod(method.getName(),method.getParameterTypes());
    javax.ws.rs.Produces methodProduces=ReflectionUtils.getAnnotation(method,javax.ws.rs.Produces.class);
    javax.ws.rs.Consumes methodConsumes=ReflectionUtils.getAnnotation(method,javax.ws.rs.Consumes.class);
    if (ReflectionUtils.isOverriddenMethod(method,cls)) {
      continue;
    }
    javax.ws.rs.Path methodPath=ReflectionUtils.getAnnotation(method,javax.ws.rs.Path.class);
    String operationPath=ReaderUtils.getPath(apiPath,methodPath,parentPath);
    if (ignoreOperationPath(operationPath,parentPath)) {
      continue;
    }
    Map<String,String> regexMap=new LinkedHashMap<>();
    operationPath=PathUtils.parsePath(operationPath,regexMap);
    if (operationPath != null) {
      Operation operation=parseMethod(method,globalParameters,methodProduces,classProduces,methodConsumes,classConsumes,classSecurityRequirements,classExternalDocumentation,classTags,classServers,classCallbacks);
      if (operation != null) {
        PathItem pathItemObject;
        if (openAPI.getPaths() != null && openAPI.getPaths().get(operationPath) != null) {
          pathItemObject=openAPI.getPaths().get(operationPath);
        }
 else {
          pathItemObject=new PathItemImpl();
        }
        String httpMethod=ReaderUtils.extractOperationMethod(operation,method,OpenAPIExtensions.chain());
        if (StringUtils.isBlank(httpMethod)) {
          continue;
        }
        setPathItemOperation(pathItemObject,httpMethod,operation);
        List<Parameter> operationParameters=new ArrayList<>();
        Annotation[][] paramAnnotations=ReflectionUtils.getParameterAnnotations(method);
        if (annotatedMethod == null) {
          Type[] genericParameterTypes=method.getGenericParameterTypes();
          for (int i=0; i < genericParameterTypes.length; i++) {
            final Type type=TypeFactory.defaultInstance().constructType(genericParameterTypes[i],cls);
            ResolvedParameter resolvedParameter=getParameters(type,Arrays.asList(paramAnnotations[i]),operation,classConsumes,methodConsumes);
            for (            Parameter p : resolvedParameter.parameters) {
              operationParameters.add(p);
            }
            if (resolvedParameter.requestBody != null) {
              processRequestBody(resolvedParameter.requestBody,operation,methodConsumes,classConsumes,operationParameters,paramAnnotations[i],type,method.getAnnotation(org.eclipse.microprofile.openapi.annotations.parameters.RequestBody.class));
            }
          }
        }
 else {
          for (int i=0; i < annotatedMethod.getParameterCount(); i++) {
            AnnotatedParameter param=annotatedMethod.getParameter(i);
            final Type type=TypeFactory.defaultInstance().constructType(param.getParameterType(),cls);
            ResolvedParameter resolvedParameter=getParameters(type,Arrays.asList(paramAnnotations[i]),operation,classConsumes,methodConsumes);
            for (            Parameter p : resolvedParameter.parameters) {
              operationParameters.add(p);
            }
            if (resolvedParameter.requestBody != null) {
              processRequestBody(resolvedParameter.requestBody,operation,methodConsumes,classConsumes,operationParameters,paramAnnotations[i],type,method.getAnnotation(org.eclipse.microprofile.openapi.annotations.parameters.RequestBody.class));
            }
          }
        }
        if (operationParameters.size() > 0) {
          Map<String,Parameter> params=new HashMap<>();
          if (operation.getParameters() != null) {
            for (            Parameter param : operation.getParameters()) {
              if (param.getIn() != null) {
                params.put(param.getName() + '/' + param.getIn().toString(),param);
              }
 else {
                params.put(param.getName(),param);
              }
            }
          }
          for (          Parameter operationParameter : operationParameters) {
            Parameter p=null;
            if (operationParameter.getIn() != null)             p=params.get(operationParameter.getName() + '/' + operationParameter.getIn().toString());
            if (p == null) {
              p=params.get(operationParameter.getName());
            }
            if (p != null) {
              ReaderUtils.copyParamValues(p,operationParameter);
            }
 else {
              operation.addParameter(operationParameter);
            }
          }
        }
        paths.addPathItem(operationPath,pathItemObject);
        if (openAPI.getPaths() != null) {
          this.paths.putAll(openAPI.getPaths());
        }
        openAPI.setPaths(this.paths);
      }
    }
  }
  AnnotationsUtils.getTags(apiTags,true).ifPresent(tags -> openApiTags.addAll(tags));
  if (!openApiTags.isEmpty()) {
    Set<Tag> tagsSet=new LinkedHashSet<>();
    if (openAPI.getTags() != null) {
      for (      Tag tag : openAPI.getTags()) {
        if (tagsSet.stream().noneMatch(t -> t.getName().equals(tag.getName()))) {
          tagsSet.add(tag);
        }
      }
    }
    for (    Tag tag : openApiTags) {
      if (tagsSet.stream().noneMatch(t -> t.getName().equals(tag.getName()))) {
        tagsSet.add(tag);
      }
    }
    openAPI.setTags(new ArrayList<>(tagsSet));
  }
  handleOpenAPIDefinition(ReflectionUtils.getAnnotation(cls,OpenAPIDefinition.class));
  if (!isEmptyComponents(components) && openAPI.getComponents() == null) {
    openAPI.setComponents(components);
  }
  return openAPI;
}

Fixed version (ground truth):
public OpenAPI read(Class<?> cls,String parentPath){
  List<org.eclipse.microprofile.openapi.annotations.security.SecurityScheme> apiSecurityScheme=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.security.SecurityScheme.class);
  List<org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement> apiSecurityRequirements=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement.class);
  List<org.eclipse.microprofile.openapi.annotations.servers.Server> apiServers=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.servers.Server.class);
  List<org.eclipse.microprofile.openapi.annotations.callbacks.Callback> apiCallbacks=ReflectionUtils.getRepeatableAnnotations(cls,org.eclipse.microprofile.openapi.annotations.callbacks.Callback.class);
  ExternalDocumentation apiExternalDocs=ReflectionUtils.getAnnotation(cls,ExternalDocumentation.class);
  org.eclipse.microprofile.openapi.annotations.tags.Tag[] apiTags=ReflectionUtils.getRepeatableAnnotationsArray(cls,org.eclipse.microprofile.openapi.annotations.tags.Tag.class);
  org.eclipse.microprofile.openapi.annotations.tags.Tags tagsAnnotation=ReflectionUtils.getAnnotation(cls,org.eclipse.microprofile.openapi.annotations.tags.Tags.class);
  javax.ws.rs.Consumes classConsumes=ReflectionUtils.getAnnotation(cls,javax.ws.rs.Consumes.class);
  javax.ws.rs.Produces classProduces=ReflectionUtils.getAnnotation(cls,javax.ws.rs.Produces.class);
  if (apiSecurityScheme != null) {
    for (    org.eclipse.microprofile.openapi.annotations.security.SecurityScheme securitySchemeAnnotation : apiSecurityScheme) {
      Optional<SecurityScheme> securityScheme=SecurityParser.getSecurityScheme(securitySchemeAnnotation);
      if (securityScheme.isPresent()) {
        Map<String,SecurityScheme> securitySchemeMap=new HashMap<>();
        if (StringUtils.isNotBlank(((SecuritySchemeImpl)securityScheme.get()).getSchemeName())) {
          securitySchemeMap.put(((SecuritySchemeImpl)securityScheme.get()).getSchemeName(),securityScheme.get());
          if (components.getSecuritySchemes() != null && components.getSecuritySchemes().size() != 0) {
            components.getSecuritySchemes().putAll(securitySchemeMap);
          }
 else {
            components.setSecuritySchemes(securitySchemeMap);
          }
        }
      }
    }
  }
  List<SecurityRequirement> classSecurityRequirements=new ArrayList<>();
  if (apiSecurityRequirements != null) {
    Optional<List<SecurityRequirement>> requirementsObject=SecurityParser.getSecurityRequirements(apiSecurityRequirements.toArray(new org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement[apiSecurityRequirements.size()]));
    if (requirementsObject.isPresent()) {
      classSecurityRequirements=requirementsObject.get();
    }
  }
  List<org.eclipse.microprofile.openapi.models.servers.Server> classServers=new ArrayList<>();
  if (apiServers != null) {
    Optional<List<org.eclipse.microprofile.openapi.models.servers.Server>> serversObject=AnnotationsUtils.getServers(apiServers.toArray(new org.eclipse.microprofile.openapi.annotations.servers.Server[apiServers.size()]));
    if (serversObject.isPresent()) {
      classServers=serversObject.get();
    }
  }
  Map<String,Callback> classCallbacks=null;
  if (apiCallbacks != null) {
    Map<String,Callback> callbacks=new LinkedHashMap<>();
    for (    org.eclipse.microprofile.openapi.annotations.callbacks.Callback classCallback : apiCallbacks) {
      Map<String,Callback> currentCallbacks=getCallbacks(classCallback);
      callbacks.putAll(currentCallbacks);
    }
    if (callbacks.size() > 0) {
      classCallbacks=callbacks;
    }
  }
  final Set<String> classTags=new LinkedHashSet<>();
  if (apiTags != null) {
    AnnotationsUtils.getTags(apiTags,false).ifPresent(tags -> tags.stream().map(t -> t.getName()).forEach(t -> classTags.add(t)));
  }
  if (tagsAnnotation != null && tagsAnnotation.refs() != null) {
    classTags.addAll(Stream.of(tagsAnnotation.refs()).filter(StringUtils::isNotBlank).collect(Collectors.toList()));
  }
  Optional<org.eclipse.microprofile.openapi.models.ExternalDocumentation> classExternalDocumentation=AnnotationsUtils.getExternalDocumentation(apiExternalDocs);
  final javax.ws.rs.Path apiPath=ReflectionUtils.getAnnotation(cls,javax.ws.rs.Path.class);
  JavaType classType=TypeFactory.defaultInstance().constructType(cls);
  BeanDescription bd=Json.mapper().getSerializationConfig().introspect(classType);
  final List<Parameter> globalParameters=new ArrayList<>();
  globalParameters.addAll(ReaderUtils.collectConstructorParameters(cls,components,classConsumes));
  globalParameters.addAll(ReaderUtils.collectFieldParameters(cls,components,classConsumes));
  Method methods[]=cls.getMethods();
  for (  Method method : methods) {
    if (isOperationHidden(method)) {
      continue;
    }
    AnnotatedMethod annotatedMethod=bd.findMethod(method.getName(),method.getParameterTypes());
    javax.ws.rs.Produces methodProduces=ReflectionUtils.getAnnotation(method,javax.ws.rs.Produces.class);
    javax.ws.rs.Consumes methodConsumes=ReflectionUtils.getAnnotation(method,javax.ws.rs.Consumes.class);
    if (ReflectionUtils.isOverriddenMethod(method,cls)) {
      continue;
    }
    javax.ws.rs.Path methodPath=ReflectionUtils.getAnnotation(method,javax.ws.rs.Path.class);
    String operationPath=ReaderUtils.getPath(apiPath,methodPath,parentPath);
    if (ignoreOperationPath(operationPath,parentPath)) {
      continue;
    }
    Map<String,String> regexMap=new LinkedHashMap<>();
    operationPath=PathUtils.parsePath(operationPath,regexMap);
    if (operationPath != null) {
      Operation operation=parseMethod(method,globalParameters,methodProduces,classProduces,methodConsumes,classConsumes,classSecurityRequirements,classExternalDocumentation,classTags,classServers,classCallbacks);
      if (operation != null) {
        PathItem pathItemObject;
        if (openAPI.getPaths() != null && openAPI.getPaths().get(operationPath) != null) {
          pathItemObject=openAPI.getPaths().get(operationPath);
        }
 else {
          pathItemObject=new PathItemImpl();
        }
        String httpMethod=ReaderUtils.extractOperationMethod(operation,method,OpenAPIExtensions.chain());
        if (StringUtils.isBlank(httpMethod)) {
          continue;
        }
        setPathItemOperation(pathItemObject,httpMethod,operation);
        org.eclipse.microprofile.openapi.annotations.parameters.RequestBody methodRequestBody=method.getAnnotation(org.eclipse.microprofile.openapi.annotations.parameters.RequestBody.class);
        List<Parameter> operationParameters=new ArrayList<>();
        Annotation[][] paramAnnotations=ReflectionUtils.getParameterAnnotations(method);
        if (annotatedMethod == null) {
          Type[] genericParameterTypes=method.getGenericParameterTypes();
          for (int i=0; i < genericParameterTypes.length; i++) {
            final Type type=TypeFactory.defaultInstance().constructType(genericParameterTypes[i],cls);
            ResolvedParameter resolvedParameter=getParameters(type,Arrays.asList(paramAnnotations[i]),operation,classConsumes,methodConsumes);
            for (            Parameter p : resolvedParameter.parameters) {
              operationParameters.add(p);
            }
            if (resolvedParameter.requestBody != null) {
              processRequestBody(resolvedParameter.requestBody,operation,methodConsumes,classConsumes,paramAnnotations[i],methodRequestBody);
            }
          }
        }
 else {
          for (int i=0; i < annotatedMethod.getParameterCount(); i++) {
            AnnotatedParameter param=annotatedMethod.getParameter(i);
            final Type type=TypeFactory.defaultInstance().constructType(param.getParameterType(),cls);
            ResolvedParameter resolvedParameter=getParameters(type,Arrays.asList(paramAnnotations[i]),operation,classConsumes,methodConsumes);
            for (            Parameter p : resolvedParameter.parameters) {
              operationParameters.add(p);
            }
            if (resolvedParameter.requestBody != null) {
              processRequestBody(resolvedParameter.requestBody,operation,methodConsumes,classConsumes,paramAnnotations[i],methodRequestBody);
            }
          }
        }
        if (operation.getRequestBody() == null) {
          processRequestBody(new ParameterImpl(),operation,methodConsumes,classConsumes,null,methodRequestBody);
        }
        if (operationParameters.size() > 0) {
          Map<String,Parameter> params=new HashMap<>();
          if (operation.getParameters() != null) {
            for (            Parameter param : operation.getParameters()) {
              if (param.getIn() != null) {
                params.put(param.getName() + '/' + param.getIn().toString(),param);
              }
 else {
                params.put(param.getName(),param);
              }
            }
          }
          for (          Parameter operationParameter : operationParameters) {
            Parameter p=null;
            if (operationParameter.getIn() != null)             p=params.get(operationParameter.getName() + '/' + operationParameter.getIn().toString());
            if (p == null) {
              p=params.get(operationParameter.getName());
            }
            if (p != null) {
              ReaderUtils.copyParamValues(p,operationParameter);
            }
 else {
              operation.addParameter(operationParameter);
            }
          }
        }
        paths.addPathItem(operationPath,pathItemObject);
        if (openAPI.getPaths() != null) {
          this.paths.putAll(openAPI.getPaths());
        }
        openAPI.setPaths(this.paths);
      }
    }
  }
  AnnotationsUtils.getTags(apiTags,true).ifPresent(tags -> openApiTags.addAll(tags));
  if (!openApiTags.isEmpty()) {
    Set<Tag> tagsSet=new LinkedHashSet<>();
    if (openAPI.getTags() != null) {
      for (      Tag tag : openAPI.getTags()) {
        if (tagsSet.stream().noneMatch(t -> t.getName().equals(tag.getName()))) {
          tagsSet.add(tag);
        }
      }
    }
    for (    Tag tag : openApiTags) {
      if (tagsSet.stream().noneMatch(t -> t.getName().equals(tag.getName()))) {
        tagsSet.add(tag);
      }
    }
    openAPI.setTags(new ArrayList<>(tagsSet));
  }
  handleOpenAPIDefinition(ReflectionUtils.getAnnotation(cls,OpenAPIDefinition.class));
  if (!isEmptyComponents(components) && openAPI.getComponents() == null) {
    openAPI.setComponents(components);
  }
  return openAPI;
}