structurizr / export

Export models and views to external formats.
https://docs.structurizr.com/export
Apache License 2.0
18 stars 28 forks source link

StructurizrPlantUMLExporter crashes when used in native binaries #47

Closed dylanwatsonsoftware closed 1 year ago

dylanwatsonsoftware commented 1 year ago

Problem: If StructurizrPlantUMLExporter is compiled into a native binary with graalvm, it crashes at runtime since AWT classes are not available,

Context: The plant UML exporter uses java.awt.image.BufferedImage to determine the icon size but this is not available on the classpath currently in graalvm builds.

There is currently an UnsatisfiedLinkError that is thrown when this happens but since the try/catch handler in the method that uses BufferedImage is only catching Exception, this isn't caught.

Solution: I believe the simplest solution is to simply catch ANY Throwables inStructurizrPlantUMLExporter#calculateIconScale This will allow the process to continue on, without completely failing. Possibly we could just also just swallow UnsatisfiedLinkErrors rather than printing the stacktrace in that case, since this is a known error and not one we'd want to spam the logs for.