7373import java .util .EnumSet ;
7474import java .util .LinkedHashMap ;
7575import java .util .Map ;
76+ import java .util .Set ;
7677import java .util .StringTokenizer ;
7778import java .util .concurrent .Callable ;
7879import java .util .concurrent .Executors ;
@@ -2175,7 +2176,9 @@ public void setDefaultBucketLocation(NSPopUpButton b) {
21752176 this .defaultBucketLocation = b ;
21762177 this .defaultBucketLocation .setAutoenablesItems (false );
21772178 this .defaultBucketLocation .removeAllItems ();
2178- ProtocolFactory .get ().forType (Protocol .Type .s3 ).getRegions ().stream ().sorted (Comparator .comparing (Location .Name ::toString )).forEach (location -> {
2179+ final Protocol protocol = ProtocolFactory .get ().forType (Protocol .Type .s3 );
2180+ final Set <Location .Name > regions = null == protocol ? Collections .emptySet () : protocol .getRegions ();
2181+ regions .stream ().sorted (Comparator .comparing (Location .Name ::toString )).forEach (location -> {
21792182 this .defaultBucketLocation .addItemWithTitle (location .toString ());
21802183 this .defaultBucketLocation .lastItem ().setRepresentedObject (location .getIdentifier ());
21812184 });
@@ -2197,7 +2200,9 @@ public void setDefaultStorageClassPopup(NSPopUpButton b) {
21972200 this .defaultStorageClassPopup = b ;
21982201 this .defaultStorageClassPopup .setAutoenablesItems (false );
21992202 this .defaultStorageClassPopup .removeAllItems ();
2200- for (String s : PreferencesReader .toList (ProtocolFactory .get ().forType (Protocol .Type .s3 ).getProperties ().get ("s3.storage.class.options" ))) {
2203+ final Protocol protocol = ProtocolFactory .get ().forType (Protocol .Type .s3 );
2204+ final Map <String , String > properties = null == protocol ? Collections .emptyMap () : protocol .getProperties ();
2205+ for (String s : PreferencesReader .toList (properties .get ("s3.storage.class.options" ))) {
22012206 this .defaultStorageClassPopup .addItemWithTitle (LocaleFactory .localizedString (s , "S3" ));
22022207 this .defaultStorageClassPopup .lastItem ().setRepresentedObject (s );
22032208 }
@@ -2273,7 +2278,9 @@ public void setDefaultBucketLocationGoogleStorage(NSPopUpButton b) {
22732278 this .defaultBucketLocationGoogleStorage = b ;
22742279 this .defaultBucketLocationGoogleStorage .setAutoenablesItems (false );
22752280 this .defaultBucketLocationGoogleStorage .removeAllItems ();
2276- ProtocolFactory .get ().forType (Protocol .Type .googlestorage ).getRegions ().stream ().sorted (Comparator .comparing (Location .Name ::toString )).forEach (location -> {
2281+ final Protocol protocol = ProtocolFactory .get ().forType (Protocol .Type .googlestorage );
2282+ final Set <Location .Name > regions = null == protocol ? Collections .emptySet () : protocol .getRegions ();
2283+ regions .stream ().sorted (Comparator .comparing (Location .Name ::toString )).forEach (location -> {
22772284 this .defaultBucketLocationGoogleStorage .addItemWithTitle (location .toString ());
22782285 this .defaultBucketLocationGoogleStorage .lastItem ().setRepresentedObject (location .getIdentifier ());
22792286 });
0 commit comments