From b35ed4cb299d30604650d4d55cb32ea842f505c8 Mon Sep 17 00:00:00 2001 From: Hanxiao Liu Date: Mon, 7 Sep 2020 11:59:30 +0800 Subject: [PATCH] Fix possible NPE in function run configuration producer (#4583) * Fix possible NPE in function run configuration producer * Fix checkstyle --- .../functions/FunctionRunConfigurationProducer.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/FunctionRunConfigurationProducer.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/FunctionRunConfigurationProducer.java index ec1843703f..d9f41911ef 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/FunctionRunConfigurationProducer.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/FunctionRunConfigurationProducer.java @@ -55,17 +55,17 @@ public ConfigurationFactory getConfigurationFactory() { } @Override - protected boolean setupConfigurationFromContext(AzureRunConfigurationBase configuration, ConfigurationContext context, Ref ref) { - if (!(configuration instanceof FunctionRunConfiguration || configuration instanceof FunctionDeployConfiguration)) { + protected boolean setupConfigurationFromContext(AzureRunConfigurationBase runConfigurationBase, ConfigurationContext context, Ref ref) { + if (!(runConfigurationBase instanceof FunctionRunConfiguration || runConfigurationBase instanceof FunctionDeployConfiguration)) { return false; } - final Location contextLocation = context.getLocation(); assert contextLocation != null; Location methodLocation = getAzureFunctionMethods(contextLocation); if (methodLocation == null) { return false; } + AzureRunConfigurationBase configuration = runConfigurationBase; if (configuration instanceof FunctionDeployConfiguration) { final RunManagerEx manager = RunManagerEx.getInstanceEx(context.getProject()); // since deploy configuration doesn't support, we need to create a FunctionRunConfiguration @@ -85,6 +85,8 @@ protected boolean setupConfigurationFromContext(AzureRunConfigurationBase config final Module module = findModule(runConfiguration, contextModule); if (module != null) { runConfiguration.initializeDefaults(module); + } else { + return false; } } if (StringUtils.isBlank(configuration.getName())) {