Program: 85975
Project: 85975
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();
    for (    Map.Entry<String,Set<BinaryResource>> entry : entries) {
      String folderName=entry.getKey();
      Set<BinaryResource> files=entry.getValue();
      for (      BinaryResource binaryResource : files) {
        try {
          addToZipFile(binaryResource,folderName,zs);
        }
 catch (        StorageException e) {
          e.printStackTrace();
        }
      }
    }
    if (fileExportEntity.getBaselineId() != 0) {
      for (      BinaryResource binaryResource : productService.getBinaryResourceFromBaseline(fileExportEntity.getBaselineId())) {
        addToZipFile(binaryResource,fileExportEntity.getSerialNumber(),zs);
      }
    }
    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();
    for (    Map.Entry<String,Set<BinaryResource>> entry : entries) {
      String folderName=entry.getKey();
      Set<BinaryResource> files=entry.getValue();
      for (      BinaryResource binaryResource : files) {
        try {
          addToZipFile(binaryResource,folderName,zs);
        }
 catch (        StorageException e) {
          e.printStackTrace();
        }
      }
    }
    if (fileExportEntity.getBaselineId() != null) {
      String baselineName=productBaselineService.getBaseline(fileExportEntity.getBaselineId()).getName();
      for (      BinaryResource binaryResource : productService.getBinaryResourceFromBaseline(fileExportEntity.getBaselineId())) {
        addToZipFile(binaryResource,baselineName,zs);
      }
    }
    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();
}