File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed
PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1010import com .intellij .ui .SimpleListCellRenderer ;
1111import com .intellij .ui .components .fields .ExtendableTextComponent ;
1212import com .microsoft .azure .toolkit .intellij .common .AzureComboBox ;
13+ import com .microsoft .azure .toolkit .lib .appservice .model .JavaVersion ;
14+ import com .microsoft .azure .toolkit .lib .appservice .model .Runtime ;
15+ import com .microsoft .azure .toolkit .lib .appservice .service .IAppService ;
1316import com .microsoft .azure .toolkit .lib .webapp .WebAppService ;
1417import com .microsoft .azuretools .azurecommons .helpers .NotNull ;
1518import com .microsoft .azuretools .azurecommons .helpers .Nullable ;
1922import javax .swing .*;
2023import java .util .List ;
2124import java .util .Objects ;
25+ import java .util .Optional ;
2226
2327public abstract class AppServiceComboBox <T extends AppServiceComboBoxModel > extends AzureComboBox <T > {
2428
@@ -71,6 +75,17 @@ protected String getItemText(final Object item) {
7175 }
7276 }
7377
78+ protected boolean isJavaAppService (IAppService appService ) {
79+ try {
80+ return Optional .ofNullable (appService .getRuntime ()).map (Runtime ::getJavaVersion )
81+ .map (javaVersion -> !Objects .equals (javaVersion , JavaVersion .OFF ))
82+ .orElse (false );
83+ } catch (final RuntimeException e ) {
84+ // app service may have been removed while parsing, return false in this case
85+ return false ;
86+ }
87+ }
88+
7489 protected abstract void createResource ();
7590
7691 public static class AppComboBoxRender extends SimpleListCellRenderer {
Original file line number Diff line number Diff line change 99import com .microsoft .azure .toolkit .intellij .appservice .AppServiceComboBox ;
1010import com .microsoft .azure .toolkit .lib .Azure ;
1111import com .microsoft .azure .toolkit .lib .appservice .AzureAppService ;
12- import com .microsoft .azure .toolkit .lib .appservice .model .JavaVersion ;
1312import com .microsoft .azure .toolkit .lib .common .operation .AzureOperation ;
1413import com .microsoft .azuretools .azurecommons .helpers .NotNull ;
1514import com .microsoft .tooling .msservices .components .DefaultLoader ;
@@ -44,7 +43,7 @@ protected void createResource() {
4443 )
4544 protected List <FunctionAppComboBoxModel > loadAppServiceModels () {
4645 return Azure .az (AzureAppService .class ).functionApps ().parallelStream ()
47- .filter (functionApp -> functionApp . getRuntime (). getJavaVersion () != JavaVersion . OFF )
46+ .filter (this :: isJavaAppService )
4847 .map (FunctionAppComboBoxModel ::new )
4948 .sorted ((app1 , app2 ) -> app1 .getAppName ().compareToIgnoreCase (app2 .getAppName ()))
5049 .collect (Collectors .toList ());
Original file line number Diff line number Diff line change @@ -49,10 +49,10 @@ protected void createResource() {
4949 )
5050 protected List <WebAppComboBoxModel > loadAppServiceModels () {
5151 final List <IWebApp > webApps = Azure .az (AzureAppService .class ).webapps (false );
52- return webApps .stream ()
53- .filter (webApp -> webApp . getRuntime (). getJavaVersion () != null && webApp . getRuntime (). getJavaVersion () != JavaVersion . OFF )
54- .sorted ((a , b ) -> a .name ().compareToIgnoreCase (b .name ()))
55- .map (WebAppComboBoxModel ::new )
56- .collect (Collectors .toList ());
52+ return webApps .stream (). parallel ()
53+ .filter (this :: isJavaAppService )
54+ .sorted ((a , b ) -> a .name ().compareToIgnoreCase (b .name ()))
55+ .map (WebAppComboBoxModel ::new )
56+ .collect (Collectors .toList ());
5757 }
5858}
You can’t perform that action at this time.
0 commit comments