From 270938cd1ad13ded10298a4b2128856fac8e2d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 7 Nov 2023 12:12:07 +0100 Subject: [PATCH] Fix possible NPE in AbstractApplication as seen in integration tests --- .../p2tools/copiedfromp2/AbstractApplication.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/AbstractApplication.java b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/AbstractApplication.java index c30544d512..52e22d35dc 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/AbstractApplication.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/AbstractApplication.java @@ -277,11 +277,19 @@ public IArtifactRepository getCompositeArtifactRepository() { } public boolean hasArtifactSources() { - return ((ICompositeRepository) getCompositeArtifactRepository()).getChildren().size() > 0; + IArtifactRepository repository = getCompositeArtifactRepository(); + if (repository instanceof ICompositeRepository composite) { + return composite.getChildren().size() > 0; + } + return false; } public boolean hasMetadataSources() { - return ((ICompositeRepository) getCompositeMetadataRepository()).getChildren().size() > 0; + IMetadataRepository repository = getCompositeMetadataRepository(); + if (repository instanceof ICompositeRepository composite) { + return composite.getChildren().size() > 0; + } + return false; } public abstract IStatus run(IProgressMonitor monitor) throws ProvisionException;