Program: 85976
Project: 85976
Buggy source:
@Override public void writeTo(FileExportEntity fileExportEntity,Class<?> aClass,Type type,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,Object> multivaluedMap,OutputStream outputStream) throws IOException, WebApplicationException {
  ZipOutputStream zs=new ZipOutputStream(outputStream);
  try {
    Map<String,Set<BinaryResource>> binariesInTree=productService.getBinariesInTree(fileExportEntity.getBaselineId(),fileExportEntity.getConfigurationItemKey().getWorkspace(),fileExportEntity.getConfigurationItemKey(),fileExportEntity.getPsFilter(),fileExportEntity.isExportNativeCADFile(),fileExportEntity.isExportDocumentLinks());
    Set<Map.Entry<String,Set<BinaryResource>>> entries=binariesInTree.entrySet();
    List<BinaryResource> baselinedSources=new ArrayList<>();
    if (fileExportEntity.isExportDocumentLinks() && fileExportEntity.getBaselineId() != null) {
      baselinedSources=productService.getBinaryResourceFromBaseline(fileExportEntity.getBaselineId());
      String baselineName=productBaselineService.getBaseline(fileExportEntity.getBaselineId()).getName();
      for (      BinaryResource binaryResource : baselinedSources) {
        addToZipFile(binaryResource,baselineName,zs);
      }
    }
    for (    Map.Entry<String,Set<BinaryResource>> entry : entries) {
      String folderName=entry.getKey();
      Set<BinaryResource> files=entry.getValue();
      for (      BinaryResource binaryResource : files) {
        if (!baselinedSources.contains(binaryResource)) {
          try {
            if (binaryResource.isNativeCADFile()) {
              folderName="String_Node_Str" + folderName;
            }
            addToZipFile(binaryResource,folderName,zs);
          }
 catch (          StorageException e) {
            e.printStackTrace();
          }
        }
      }
    }
    if (fileExportEntity.getSerialNumber() != null) {
      addProductInstanceDataToZip(zs,fileExportEntity.getConfigurationItemKey(),fileExportEntity.getSerialNumber());
    }
  }
 catch (  UserNotFoundException e) {
    e.printStackTrace();
  }
catch (  UserNotActiveException e) {
    e.printStackTrace();
  }
catch (  WorkspaceNotFoundException e) {
    e.printStackTrace();
  }
catch (  ConfigurationItemNotFoundException e) {
    e.printStackTrace();
  }
catch (  NotAllowedException e) {
    e.printStackTrace();
  }
catch (  EntityConstraintException e) {
    e.printStackTrace();
  }
catch (  PartMasterNotFoundException e) {
    e.printStackTrace();
  }
catch (  ProductInstanceMasterNotFoundException e) {
    e.printStackTrace();
  }
catch (  StorageException e) {
    e.printStackTrace();
  }
catch (  BaselineNotFoundException e) {
    e.printStackTrace();
  }
  zs.close();
}

Fixed version (ground truth):
@Override public void writeTo(FileExportEntity fileExportEntity,Class<?> aClass,Type type,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,Object> multivaluedMap,OutputStream outputStream) throws IOException, WebApplicationException {
  ZipOutputStream zs=new ZipOutputStream(outputStream);
  try {
    Map<String,Set<BinaryResource>> binariesInTree=productService.getBinariesInTree(fileExportEntity.getBaselineId(),fileExportEntity.getConfigurationItemKey().getWorkspace(),fileExportEntity.getConfigurationItemKey(),fileExportEntity.getPsFilter(),fileExportEntity.isExportNativeCADFile(),fileExportEntity.isExportDocumentLinks());
    Set<Map.Entry<String,Set<BinaryResource>>> entries=binariesInTree.entrySet();
    List<BinaryResource> baselinedSources=new ArrayList<>();
    List<String> baselinedSourcesName=new ArrayList<>();
    if (fileExportEntity.isExportDocumentLinks() && fileExportEntity.getBaselineId() != null) {
      baselinedSources=productService.getBinaryResourceFromBaseline(fileExportEntity.getBaselineId());
      for (      BinaryResource binary : baselinedSources) {
        baselinedSourcesName.add(binary.getName());
      }
      String baselineName=productBaselineService.getBaseline(fileExportEntity.getBaselineId()).getName();
      for (      BinaryResource binaryResource : baselinedSources) {
        addToZipFile(binaryResource,baselineName,zs);
      }
    }
    for (    Map.Entry<String,Set<BinaryResource>> entry : entries) {
      String folderName=entry.getKey();
      Set<BinaryResource> files=entry.getValue();
      for (      BinaryResource binaryResource : files) {
        if (!baselinedSourcesName.contains(binaryResource.getName())) {
          try {
            if (binaryResource.isNativeCADFile()) {
              folderName="String_Node_Str" + folderName;
            }
            addToZipFile(binaryResource,folderName,zs);
          }
 catch (          StorageException e) {
            e.printStackTrace();
          }
        }
      }
    }
    if (fileExportEntity.getSerialNumber() != null) {
      addProductInstanceDataToZip(zs,fileExportEntity.getConfigurationItemKey(),fileExportEntity.getSerialNumber());
    }
  }
 catch (  UserNotFoundException e) {
    e.printStackTrace();
  }
catch (  UserNotActiveException e) {
    e.printStackTrace();
  }
catch (  WorkspaceNotFoundException e) {
    e.printStackTrace();
  }
catch (  ConfigurationItemNotFoundException e) {
    e.printStackTrace();
  }
catch (  NotAllowedException e) {
    e.printStackTrace();
  }
catch (  EntityConstraintException e) {
    e.printStackTrace();
  }
catch (  PartMasterNotFoundException e) {
    e.printStackTrace();
  }
catch (  ProductInstanceMasterNotFoundException e) {
    e.printStackTrace();
  }
catch (  StorageException e) {
    e.printStackTrace();
  }
catch (  BaselineNotFoundException e) {
    e.printStackTrace();
  }
  zs.close();
}