diff --git a/docs/openapi.json b/docs/openapi.json index 355477d0..b3ffb08f 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1478,9 +1478,6 @@ "type": "string" } }, - "required": [ - "documentType" - ], "type": "object" }, "FormDataBodyPart": { diff --git a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/util/PdfExporterFileResourceProvider.java b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/util/PdfExporterFileResourceProvider.java index 6449a1f4..cdf224c3 100644 --- a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/util/PdfExporterFileResourceProvider.java +++ b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/util/PdfExporterFileResourceProvider.java @@ -34,7 +34,7 @@ public class PdfExporterFileResourceProvider implements FileResourceProvider { private final List resolvers; public PdfExporterFileResourceProvider() { - this.resolvers = Arrays.asList(removeGenericUrlResolver(PolarionUrlResolver.getInstance()), new CustomResourceUrlResolver()); + this.resolvers = Arrays.asList(getPolarionUrlResolverWithoutGenericUrlChildResolver(), new CustomResourceUrlResolver()); } @VisibleForTesting @@ -105,13 +105,21 @@ public byte[] processPossibleSvgImage(byte[] possibleSvgImageBytes) { * Remove GenericUrlResolver because it has no explicit timeouts declared */ @SneakyThrows - private IUrlResolver removeGenericUrlResolver(IAttachmentUrlResolver urlResolver) { - if (urlResolver instanceof ParentUrlResolver parentUrlResolver) { + private IAttachmentUrlResolver getPolarionUrlResolverWithoutGenericUrlChildResolver() { + IAttachmentUrlResolver attachmentUrlResolver = PolarionUrlResolver.getInstance(); + + if (attachmentUrlResolver instanceof ParentUrlResolver parentUrlResolver) { Field childResolversField = ParentUrlResolver.class.getDeclaredField("childResolvers"); childResolversField.setAccessible(true); - ((List) childResolversField.get(parentUrlResolver)).removeIf(resolver -> resolver instanceof GenericUrlResolver); + + @SuppressWarnings("unchecked") + List childResolvers = ((List) childResolversField.get(parentUrlResolver)).stream() + .filter(resolver -> !(resolver instanceof GenericUrlResolver)) + .toList(); + + return new ParentUrlResolver(childResolvers); } - return urlResolver; + + return attachmentUrlResolver; } } -