Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchElementException when trying to export an empty diagram as SVG #1194

Closed
4 tasks done
pcdavid opened this issue Apr 28, 2022 · 1 comment · Fixed by #1221
Closed
4 tasks done

NoSuchElementException when trying to export an empty diagram as SVG #1194

pcdavid opened this issue Apr 28, 2022 · 1 comment · Fixed by #1221

Comments

@pcdavid
Copy link
Member

pcdavid commented Apr 28, 2022

  • I have checked that this bug has not yet been reported by someone else
  • I have checked that this bug appears on Chrome
  • I have specified the version : 2022.3.9
  • I have specified my environment : Linux

Steps to reproduce

  1. Create an empty diagram
  2. Try to export it as SVG using the context menu in the explorer
  3. Nothing happens from the user's point of view, but an exception is logged on the backend:
Caused by: java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.get(Optional.java:148) ~[na:na]
	at org.eclipse.sirius.components.collaborative.diagrams.export.svg.DiagramExportService.computeViewBox(DiagramExportService.java:116) ~[classes/:na]
	at org.eclipse.sirius.components.collaborative.diagrams.export.svg.DiagramExportService.addSvgRoot(DiagramExportService.java:78) ~[classes/:na]
	at org.eclipse.sirius.components.collaborative.diagrams.export.svg.DiagramExportService.export(DiagramExportService.java:59) ~[classes/:na]
	at org.eclipse.sirius.components.collaborative.diagrams.handlers.ExportDiagramEventHandler.handle(ExportDiagramEventHandler.java:51) ~[classes/:na]

Why would someone want to export an empty diagram? Here in the example scenario it's triggered manually, but it could be part of a programmatic export/publication of all the diagrams in a project for example.

The technical issue is here when the code does this.xBeginPositions.stream().min(Double::compare).get(); on lists like xBeginPositions that might be empty (which is the case on an empty diagram).

@pcdavid
Copy link
Member Author

pcdavid commented Apr 28, 2022

Note that the "SonarLint for Eclipse" plug-in highlights this potential issue when opening the file (that's how I found it when looking for something else in that file).

@gcoutable gcoutable self-assigned this May 16, 2022
@gcoutable gcoutable added this to the 2022.5.0 milestone May 16, 2022
gcoutable added a commit that referenced this issue May 17, 2022
Bug: #1194
Signed-off-by: Guillaume Coutable <[email protected]>
@gcoutable gcoutable linked a pull request May 17, 2022 that will close this issue
39 tasks
sbegaudeau pushed a commit that referenced this issue May 18, 2022
Bug: #1194
Signed-off-by: Guillaume Coutable <[email protected]>
sbegaudeau pushed a commit that referenced this issue May 18, 2022
Bug: #1194
Signed-off-by: Guillaume Coutable <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants