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

Add log for ignored excepton #9302

Merged
merged 13 commits into from
Dec 19, 2022
Merged
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/gui/JabRefExecutorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void executeAndWait(Runnable command) {
Future<?> future = executorService.submit(command);
try {
future.get();
} catch (InterruptedException ignored) {
// Ignored
} catch (InterruptedException e) {
LOGGER.error("The thread is waiting, occupied or interrupted", e);
} catch (ExecutionException e) {
LOGGER.error("Problem executing command", e);
}
Expand Down Expand Up @@ -110,8 +110,8 @@ public void executeInterruptableTaskAndWait(Runnable runnable) {
Future<?> future = lowPriorityExecutorService.submit(runnable);
try {
future.get();
} catch (InterruptedException ignored) {
// Ignored
} catch (InterruptedException e) {
LOGGER.error("The thread is waiting, occupied or interrupted", e);
} catch (ExecutionException e) {
LOGGER.error("Problem executing command", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ private List<BibEntry> tryImportFormats(String data) {
try {
UnknownFormatImport unknownFormatImport = importFormatReader.importUnknownFormat(data);
return unknownFormatImport.parserResult.getDatabase().getEntries();
} catch (ImportException ignored) {
} catch (ImportException ex) {
dialogService.notify(Localization.lang("ImportError: UnknownFormat"));
LOGGER.info("Detail: Found UnknownFormat in clipboard but it is not a suitable importer", ex);
return Collections.emptyList();
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ private void setupValidation() {
try {
Pattern.compile(input);
return true;
} catch (PatternSyntaxException ignored) {
} catch (PatternSyntaxException e) {
// Ignored
return false;
}
},
Expand Down Expand Up @@ -210,7 +211,8 @@ private void setupValidation() {
try {
Pattern.compile(input);
return true;
} catch (PatternSyntaxException ignored) {
} catch (PatternSyntaxException e) {
// Ignored
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ private static Optional<Charset> getSuppliedEncoding(BufferedReader reader) {
return Optional.empty();
}
}
} catch (IOException ignored) {
LOGGER.error("Supplied encoding could not be determined", ignored);
} catch (IOException e) {
LOGGER.error("Supplied encoding could not be determined", e);
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.StandardEntryType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Importer for the ISI Web of Science, INSPEC and Medline format.
* <p>
Expand All @@ -39,7 +42,7 @@
* </ul>
*/
public class IsiImporter extends Importer {

private static final Logger LOGGER = LoggerFactory.getLogger(IsiImporter.class);
private static final Pattern SUB_SUP_PATTERN = Pattern.compile("/(sub|sup)\\s+(.*?)\\s*/");

// 2006.09.05: Modified pattern to avoid false positives for other files due to an
Expand Down Expand Up @@ -344,8 +347,9 @@ static String parseMonth(String value) {
if (month.isPresent()) {
return month.get().getJabRefFormat();
}
} catch (NumberFormatException ignored) {
// Ignored
} catch (NumberFormatException e) {
LOGGER.info("The import file in ISI format cannot parse part of the content in PD into integers " +
"(If there is no month or PD displayed in the imported entity, this may be the reason)", e);
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static LinkedFile convert(List<String> entry) {
if (LinkedFile.isOnlineLink(entry.get(1))) {
try {
field = new LinkedFile(entry.get(0), new URL(entry.get(1)), entry.get(2));
} catch (MalformedURLException ignored) {
} catch (MalformedURLException e) {
// in case the URL is malformed, store it nevertheless
field = new LinkedFile(entry.get(0), entry.get(1), entry.get(2));
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -163,6 +163,7 @@ static LinkedFile convert(List<String> entry) {
Path path = Path.of(pathStr);
field = new LinkedFile(entry.get(0), path, entry.get(2));
} catch (InvalidPathException e) {
// Ignored
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
field = new LinkedFile(entry.get(0), pathStr, entry.get(2));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private void handleMessage(Protocol protocol, RemoteMessage type, Object argumen
public void closeServerSocket() {
try {
serverSocket.close();
} catch (IOException ignored) {
// Ignored
} catch (IOException e) {
LOGGER.warn("Unable to close server socket!", e);
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
12 changes: 6 additions & 6 deletions src/main/java/org/jabref/logic/remote/shared/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ public Pair<RemoteMessage, Object> receiveMessage() throws IOException {
public void close() {
try {
in.close();
} catch (IOException ignored) {
// Ignored
} catch (IOException e) {
LOGGER.warn("Input stream not closed", e);
}

try {
out.close();
} catch (IOException ignored) {
// Ignored
} catch (IOException e) {
LOGGER.warn("Output stream not closed", e);
}

try {
socket.close();
} catch (IOException ignored) {
// Ignored
} catch (IOException e) {
LOGGER.warn("Socket not closed", e);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/util/BuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BuildInfo(String path) {
properties.load(reader);
}
}
} catch (IOException ignored) {
} catch (IOException e) {
// nothing to do -> default already set
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/jabref/model/entry/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Objects;
import java.util.Optional;

import static org.jabref.logic.importer.IdBasedParserFetcher.LOGGER;

public class Date {

private static final DateTimeFormatter NORMALIZED_DATE_FORMATTER = DateTimeFormatter.ofPattern("uuuu[-MM][-dd]");
Expand Down Expand Up @@ -99,15 +101,16 @@ public static Optional<Date> parse(String dateString) {
TemporalAccessor parsedDate = SIMPLE_DATE_FORMATS.parse(strDates[0]);
TemporalAccessor parsedEndDate = SIMPLE_DATE_FORMATS.parse(strDates[1]);
return Optional.of(new Date(parsedDate, parsedEndDate));
} catch (DateTimeParseException ignored) {
} catch (DateTimeParseException e) {
LOGGER.warn("Invalid Date format", e);
return Optional.empty();
}
}

try {
TemporalAccessor parsedDate = SIMPLE_DATE_FORMATS.parse(dateString);
return Optional.of(new Date(parsedDate));
} catch (DateTimeParseException ignored) {
} catch (DateTimeParseException e) {
LOGGER.warn("Invalid Date format", e);
return Optional.empty();
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@ private JabRefPreferences() {

// set default theme
defaults.put(FX_THEME, Theme.BASE_CSS);

setLanguageDependentDefaultValues();
}

Expand Down Expand Up @@ -777,8 +776,8 @@ private static List<String> convertStringToList(String toConvert) {
while ((rs = getNextUnit(reader)).isPresent()) {
result.add(rs.get());
}
} catch (IOException ignored) {
// Ignored
} catch (IOException e) {
LOGGER.warn("Unable to convert String to List", e);
}
return result;
}
Expand Down