Program: 85972
Project: 85972
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<String> baselinedSourcesName=new ArrayList<>();
    if (fileExportEntity.isExportDocumentLinks() && fileExportEntity.getBaselineId() != null) {
      List<BinaryResource> baselinedSources=productService.getBinaryResourceFromBaseline(fileExportEntity.getBaselineId());
      for (      BinaryResource binary : baselinedSources) {
        baselinedSourcesName.add(binary.getName());
      }
      for (      BinaryResource binaryResource : baselinedSources) {
        addToZipFile(binaryResource,"String_Node_Str" + BinaryResource.getFolderName(binaryResource.getFullName()),zs);
      }
    }
    for (    Map.Entry<String,Set<BinaryResource>> entry : entries) {
      String partNumberFolderName=entry.getKey();
      String folderName;
      Set<BinaryResource> files=entry.getValue();
      for (      BinaryResource binaryResource : files) {
        if (!baselinedSourcesName.contains(binaryResource.getName())) {
          try {
            if (binaryResource.isNativeCADFile()) {
              folderName=partNumberFolderName + "String_Node_Str";
            }
 else             if (binaryResource.isAttachedFile()) {
              folderName=partNumberFolderName + "String_Node_Str";
            }
 else {
              folderName=partNumberFolderName;
            }
            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();
  }
  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<String> baselinedSourcesName=new ArrayList<>();
    if (fileExportEntity.isExportDocumentLinks() && fileExportEntity.getBaselineId() != null) {
      List<BinaryResource> baselinedSources=productService.getBinaryResourceFromBaseline(fileExportEntity.getBaselineId());
      for (      BinaryResource binaryResource : baselinedSources) {
        String folderName=BinaryResource.getFolderName(binaryResource.getFullName());
        baselinedSourcesName.add(folderName);
        addToZipFile(binaryResource,"String_Node_Str" + folderName,zs);
      }
    }
    for (    Map.Entry<String,Set<BinaryResource>> entry : entries) {
      String partNumberFolderName=entry.getKey();
      String folderName;
      Set<BinaryResource> files=entry.getValue();
      for (      BinaryResource binaryResource : files) {
        try {
          if (binaryResource.isNativeCADFile()) {
            folderName=partNumberFolderName + "String_Node_Str";
          }
 else           if (binaryResource.isAttachedFile()) {
            folderName=partNumberFolderName + "String_Node_Str";
          }
 else {
            folderName=partNumberFolderName;
          }
          addToZipFile(binaryResource,folderName,zs);
        }
 catch (        StorageException e) {
          e.printStackTrace();
        }
      }
    }
    if (fileExportEntity.getSerialNumber() != null) {
      addProductInstanceDataToZip(zs,fileExportEntity.getConfigurationItemKey(),fileExportEntity.getSerialNumber(),baselinedSourcesName);
    }
  }
 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();
  }
  zs.close();
}