Skip to content

Commit

Permalink
Clear internal history in case of currupted histroy file
Browse files Browse the repository at this point in the history
The expected behaviour when loading of a history files fails is that the issue is logged but the reader is usable.

The current behaviour results in a IllegalArgumentException (from the addHistoryLine(Path, String) function) which is never caught. This results is a different behaviour than for example the file permission does not allow to read the file.
As a consequence in Karaf the session is not useable because of returned "null" at some point which is interpreted as session end.

This commit introduces a fix which catches the IllegalArgumentException and keeps the reader usable without history information. Also this makes the behaviour consistent.
  • Loading branch information
mkrueger92 authored Jan 10, 2019
1 parent 7783c03 commit 3fa0adf
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void attach(LineReader reader) {
try {
load();
}
catch (IOException e) {
catch (IllegalArgumentException | IOException e) {
Log.warn("Failed to load history", e);
}
}
Expand All @@ -90,7 +90,7 @@ public void load() throws IOException {
maybeResize();
}
}
} catch (IOException e) {
} catch (IllegalArgumentException | IOException e) {
Log.debug("Failed to load history; clearing", e);
internalClear();
throw e;
Expand Down

0 comments on commit 3fa0adf

Please # to comment.