Skip to content

Commit

Permalink
Remove instance variable requiring access to Local implementation w…
Browse files Browse the repository at this point in the history
…hile loading preferences.
  • Loading branch information
dkocher committed Oct 23, 2023
1 parent ca30c5a commit b8283ba
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
public class UserDefaultsPreferences extends DefaultPreferences {
private static final Logger log = LogManager.getLogger(UserDefaultsPreferences.class);

private final NSBundle bundle = new BundleApplicationResourcesFinder().bundle();

private final LRUCache<String, String> cache = LRUCache.usingLoader(this::loadProperty, 1000);

private static final String MISSING_PROPERTY = String.valueOf(StringUtils.INDEX_NOT_FOUND);
Expand All @@ -72,6 +70,7 @@ public String getDefault(final String property) {
// Lookup in the default map
final String value = super.getDefault(property);
if(null == value) {
final NSBundle bundle = new BundleApplicationResourcesFinder().bundle();
// Missing in default. Lookup in Info.plist
NSObject plist = bundle.infoDictionary().objectForKey(property);
if(null == plist) {
Expand Down Expand Up @@ -170,6 +169,7 @@ protected void setDefaults() {
this.setDefault("local.user.home", SystemB.INSTANCE.getpwuid(LibC.INSTANCE.getuid()).pw_dir);
}

final NSBundle bundle = new BundleApplicationResourcesFinder().bundle();
if(null != bundle) {
if(bundle.objectForInfoDictionaryKey("CFBundleName") != null) {
this.setDefault("application.name", bundle.objectForInfoDictionaryKey("CFBundleName").toString());
Expand Down Expand Up @@ -272,6 +272,7 @@ public String locale() {

@Override
public List<String> applicationLocales() {
final NSBundle bundle = new BundleApplicationResourcesFinder().bundle();
return this.toList(bundle.localizations());
}

Expand Down

0 comments on commit b8283ba

Please sign in to comment.