Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed freeze for few seconds on DNS timeout in MacOS #7482

Merged
merged 5 commits into from
Mar 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ public class JabRefPreferences implements PreferencesService {
// User
private static final String USER_ID = "userId";
private static final String EXTERNAL_JOURNAL_LISTS = "externalJournalLists";
private final String USER_NAME;
calixtus marked this conversation as resolved.
Show resolved Hide resolved

// Telemetry collection
private static final String COLLECT_TELEMETRY = "collectTelemetry";
Expand Down Expand Up @@ -679,6 +680,7 @@ private JabRefPreferences() {
defaults.put(FX_THEME, Theme.BASE_CSS);

setLanguageDependentDefaultValues();
USER_NAME = getUserName();
calixtus marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -764,12 +766,7 @@ private static void insertDefaultCleanupPreset(Map<String, Object> storage) {

@Override
public String getUser() {
try {
return get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) {
LOGGER.debug("Hostname not found.", ex);
return get(DEFAULT_OWNER);
}
return USER_NAME;
}

public void setLanguageDependentDefaultValues() {
Expand All @@ -789,6 +786,15 @@ public void setLanguageDependentDefaultValues() {
defaults.put(EMAIL_SUBJECT, Localization.lang("References"));
}

private String getUserName() {
try {
return get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) {
LOGGER.debug("Hostname not found.", ex);
return get(DEFAULT_OWNER);
}
}

/**
* Check whether a key is set (differently from null).
*
Expand Down