Program: 30143
Project: 30143
Buggy source:
/** 
 * Process annotations in a bundle descriptor, the annoation processing is dependent on the type of descriptor being passed.
 */
protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDesc,ModuleScanner scanner,ReadableArchive archive) throws AnnotationProcessorException, IOException {
  if (scanner == null) {
    return null;
  }
  AnnotatedElementHandler aeHandler=AnnotatedElementHandlerFactory.createAnnotatedElementHandler(bundleDesc);
  if (aeHandler == null) {
    return null;
  }
  Parser parser=null;
  if (archive.getParentArchive() != null) {
    parser=archive.getParentArchive().getExtraData(Parser.class);
  }
 else {
    parser=archive.getExtraData(Parser.class);
  }
  if (parser == null) {
    ParsingContext parsingContext=new ParsingContext.Builder().logger(logger).executorService(getExecutorService()).build();
    parser=new Parser(parsingContext);
  }
  scanner.process(archive,bundleDesc,classLoader,parser);
  if (!scanner.getElements().isEmpty()) {
    if (bundleDesc.isDDWithNoAnnotationAllowed()) {
      String ddName=getStandardDDFile().getDeploymentDescriptorPath();
      String explodedArchiveName=new File(archive.getURI()).getName();
      String archiveName=FileUtils.revertFriendlyFilenameExtension(explodedArchiveName);
      throw new AnnotationProcessorException(localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{ddName,archiveName,bundleDesc.getSpecVersion()}));
    }
    AnnotationProcessor ap=annotationFactory.getAnnotationProcessor();
    ProcessingContext ctx=ap.createContext();
    ctx.setArchive(archive);
    if (annotationErrorHandler != null) {
      ctx.setErrorHandler(annotationErrorHandler);
    }
    ctx.setProcessingInput(scanner);
    ctx.pushHandler(aeHandler);
    ClassLoader originalBundleClassLoader=null;
    try {
      originalBundleClassLoader=bundleDesc.getClassLoader();
    }
 catch (    Exception e) {
    }
    if (originalBundleClassLoader == null) {
      bundleDesc.setClassLoader(classLoader);
    }
    try {
      return ap.process(ctx);
    }
  finally {
      if (originalBundleClassLoader == null) {
        bundleDesc.setClassLoader(null);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Process annotations in a bundle descriptor, the annoation processing is dependent on the type of descriptor being passed.
 */
protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDesc,ModuleScanner scanner,ReadableArchive archive) throws AnnotationProcessorException, IOException {
  if (scanner == null) {
    return null;
  }
  AnnotatedElementHandler aeHandler=AnnotatedElementHandlerFactory.createAnnotatedElementHandler(bundleDesc);
  if (aeHandler == null) {
    return null;
  }
  Parser parser=null;
  if (archive.getParentArchive() != null) {
    parser=archive.getParentArchive().getExtraData(Parser.class);
  }
 else {
    parser=archive.getExtraData(Parser.class);
  }
  scanner.process(archive,bundleDesc,classLoader,parser);
  if (!scanner.getElements().isEmpty()) {
    if (bundleDesc.isDDWithNoAnnotationAllowed()) {
      String ddName=getStandardDDFile().getDeploymentDescriptorPath();
      String explodedArchiveName=new File(archive.getURI()).getName();
      String archiveName=FileUtils.revertFriendlyFilenameExtension(explodedArchiveName);
      throw new AnnotationProcessorException(localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{ddName,archiveName,bundleDesc.getSpecVersion()}));
    }
    AnnotationProcessor ap=annotationFactory.getAnnotationProcessor();
    ProcessingContext ctx=ap.createContext();
    ctx.setArchive(archive);
    if (annotationErrorHandler != null) {
      ctx.setErrorHandler(annotationErrorHandler);
    }
    ctx.setProcessingInput(scanner);
    ctx.pushHandler(aeHandler);
    ClassLoader originalBundleClassLoader=null;
    try {
      originalBundleClassLoader=bundleDesc.getClassLoader();
    }
 catch (    Exception e) {
    }
    if (originalBundleClassLoader == null) {
      bundleDesc.setClassLoader(classLoader);
    }
    try {
      return ap.process(ctx);
    }
  finally {
      if (originalBundleClassLoader == null) {
        bundleDesc.setClassLoader(null);
      }
    }
  }
  return null;
}