Skip to content

Commit

Permalink
Fix subscription npe in app service creation basic panel (#4735)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flanker32 authored Nov 9, 2020
1 parent 61c8b7a commit 5b7704a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public AzureValidationInfo doValidateValue() {
final AzureValidationInfo info = super.doValidateValue();
if (info == AzureValidationInfo.OK) {
try {
ValidationUtils.validateAppServiceName(this.subscription.subscriptionId(), this.getValue());
ValidationUtils.validateAppServiceName(subscription != null ? subscription.subscriptionId() : null, this.getValue());
} catch (final IllegalArgumentException e) {
final AzureValidationInfo.AzureValidationInfoBuilder builder = AzureValidationInfo.builder();
return builder.input(this).message(e.getMessage()).type(AzureValidationInfo.Type.ERROR).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class AppServiceInfoBasicPanel<T extends AppServiceConfig> extends JPanel
private TitledSeparator deploymentTitle;
private JLabel deploymentLabel;

private Subscription subscription;

public AppServiceInfoBasicPanel(final Project project, final Supplier<T> defaultConfigSupplier) {
super();
this.project = project;
Expand All @@ -74,7 +76,9 @@ public AppServiceInfoBasicPanel(final Project project, final Supplier<T> default
}

private void init() {
this.subscription = AzureMvpModel.getInstance().getSelectedSubscriptions().get(0);
this.textName.setRequired(true);
this.textName.setSubscription(subscription);
this.selectorPlatform.setRequired(true);

this.selectorApplication.setFileFilter(virtualFile -> {
Expand Down Expand Up @@ -109,7 +113,6 @@ public T getData() {

private T initConfig() {
final String appName = String.format("app-%s-%s", this.project.getName(), DATE_FORMAT.format(new Date()));
final Subscription subscription = AzureMvpModel.getInstance().getSelectedSubscriptions().get(0);
final DraftResourceGroup group = DraftResourceGroup.builder().build();
group.setName(StringUtils.substring(String.format("rg-%s", appName), 0, RG_NAME_MAX_LENGTH));
group.setSubscription(subscription);
Expand Down

0 comments on commit 5b7704a

Please sign in to comment.