From 09adf0b20e477abe3311d13933a1508b368307a1 Mon Sep 17 00:00:00 2001 From: Ed Merks Date: Tue, 12 Jan 2021 08:18:25 +0100 Subject: [PATCH] [570262] There's an NPE if the Index fails to load, leaving the installer with a permanent progress indicator --- .../oomph/setup/ui/wizards/SetupWizard.java | 71 ++++++++++--------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java index 96bf797b5..df7f71347 100644 --- a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java +++ b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/SetupWizard.java @@ -1367,56 +1367,59 @@ protected void indexLoaded(final Index index) { wizard.indexLoaded(index); - List jreDescriptors = new ArrayList(); - Annotation jresAnnotation = index.getAnnotation(AnnotationConstants.ANNOTATION_JRE); - if (jresAnnotation != null) + if (index != null) { - EList references = jresAnnotation.getReferences(); - for (EObject eObject : references) + List jreDescriptors = new ArrayList(); + Annotation jresAnnotation = index.getAnnotation(AnnotationConstants.ANNOTATION_JRE); + if (jresAnnotation != null) { - if (eObject instanceof Macro) + EList references = jresAnnotation.getReferences(); + for (EObject eObject : references) { - Macro jresMacro = (Macro)eObject; - EList setupTasks = jresMacro.getSetupTasks(); - LOOP: // - for (SetupTask setupTask : setupTasks) + if (eObject instanceof Macro) { - if (setupTask instanceof P2Task) + Macro jresMacro = (Macro)eObject; + EList setupTasks = jresMacro.getSetupTasks(); + LOOP: // + for (SetupTask setupTask : setupTasks) { - P2Task jreP2Task = (P2Task)setupTask; - String label = jreP2Task.getLabel(); - Matcher matcher = Pattern.compile("([1-9][0-9]*)\\.([0-9]+)\\.([0-9]+)").matcher(label); //$NON-NLS-1$ - if (matcher.find()) + if (setupTask instanceof P2Task) { - EList repositories = jreP2Task.getRepositories(); - for (Requirement requirement : jreP2Task.getRequirements()) + P2Task jreP2Task = (P2Task)setupTask; + String label = jreP2Task.getLabel(); + Matcher matcher = Pattern.compile("([1-9][0-9]*)\\.([0-9]+)\\.([0-9]+)").matcher(label); //$NON-NLS-1$ + if (matcher.find()) { - // The requirements capture filter information about arch/os combinations for which JREs are available. - // We should not offer a JRE feature for which there isn't really an actual JRE fragment for the current arch/os available. - String filter = requirement.getFilter(); - if (!matchesFilterContext(filter)) + EList repositories = jreP2Task.getRepositories(); + for (Requirement requirement : jreP2Task.getRequirements()) { - continue LOOP; + // The requirements capture filter information about arch/os combinations for which JREs are available. + // We should not offer a JRE feature for which there isn't really an actual JRE fragment for the current arch/os available. + String filter = requirement.getFilter(); + if (!matchesFilterContext(filter)) + { + continue LOOP; + } } - } - Repository repository = repositories.get(0); - JRE.Descriptor descriptor = new JRE.Descriptor(label + " - " + repository.getURL(), //$NON-NLS-1$ - Integer.parseInt(matcher.group(1)), // - Integer.parseInt(matcher.group(2)), // - Integer.parseInt(matcher.group(3)), // - 64, // - false, // - jreP2Task); - jreDescriptors.add(descriptor); + Repository repository = repositories.get(0); + JRE.Descriptor descriptor = new JRE.Descriptor(label + " - " + repository.getURL(), //$NON-NLS-1$ + Integer.parseInt(matcher.group(1)), // + Integer.parseInt(matcher.group(2)), // + Integer.parseInt(matcher.group(3)), // + 64, // + false, // + jreP2Task); + jreDescriptors.add(descriptor); + } } } } } } - } - JREManager.INSTANCE.setJREs(jreDescriptors); + JREManager.INSTANCE.setJREs(jreDescriptors); + } } @SuppressWarnings("restriction")