Skip to content

Commit 9859aae

Browse files
committed
Use proper classloader for finding SVGRasterizer #1965 #2049
When initializing the SVGFileFormat class for loading SVGs, the current context classloader is used by the ServiceLoader to find an SVGRasterizer implementation. This classloader may be incorrect in some cases, i.e., it may not be the plain system classloader or an according OSGi classloader but, e.g., some specific classloader for test execution. This change makes the ServiceLoader use the same classloader for finding an SVGRasterizer implementation than the classloader of the SVGFileFormat class containing the rasterizer reference itself. Fixes #1965 Fixes #2049
1 parent bfcadf9 commit 9859aae

File tree

1 file changed

+2
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image

1 file changed

+2
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/SVGFileFormat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
public class SVGFileFormat extends FileFormat {
3232

3333
/** The instance of the registered {@link SVGRasterizer}. */
34-
private static final SVGRasterizer RASTERIZER = ServiceLoader.load(SVGRasterizer.class).findFirst().orElse(null);
34+
private static final SVGRasterizer RASTERIZER = ServiceLoader
35+
.load(SVGRasterizer.class, SVGFileFormat.class.getClassLoader()).findFirst().orElse(null);
3536

3637
@Override
3738
boolean isFileFormat(LEDataInputStream stream) throws IOException {

0 commit comments

Comments
 (0)