Skip to content

Remove error message on recovery success#1856

Merged
ctubbsii merged 1 commit intoapache:mainfrom
ctubbsii:fix-error-msg-on-recovery-success
Jan 7, 2021
Merged

Remove error message on recovery success#1856
ctubbsii merged 1 commit intoapache:mainfrom
ctubbsii:fix-error-msg-on-recovery-success

Conversation

@ctubbsii
Copy link
Copy Markdown
Member

@ctubbsii ctubbsii commented Jan 6, 2021

Fix an error message that the stream is closed after a successful
recovery in LogSorter.java. This occurred because a try-with-resources
block automatically closed the file input stream, and then it was
attempted to be closed again in the finally block in the
LogSorter.LogProcessor.sort() method. This resulted in an error message
always being shown in the finally block, even if the try-with-resources
block successfully finished without error and closed the input stream
already. This change removes the use of try-with-resources, and relies
on the finally block to close the resources once.

Related changes include:

  • Remove unnecessary wrapping class to carry the original input stream
    alongside the decrypting wrapper input stream, since the original
    input stream is already available to all callers, and it was only used
    to get the decrypting wrapper input stream. The decrypting input
    stream can now be retrieved directly instead of placing it in a new
    holder object. The method to get the decrypting stream was renamed and
    a javadoc was added to make it easier to understand what it does.
  • Change LogHeaderIncompleteException to not be a subclass of
    IOException, so that it can be explicitly caught, and not easily
    overlooked when handling other IOExceptions. Its cause parameter type
    was also narrowed to the EOFException, which is the only valid
    exception to cause the LogHeaderIncompleteException to be thrown.

Fix an error message that the stream is closed after a successful
recovery in LogSorter.java. This occurred because a try-with-resources
block automatically closed the file input stream, and then it was
attempted to be closed again in the finally block in the
LogSorter.LogProcessor.sort() method. This resulted in an error message
always being shown in the finally block, even if the try-with-resources
block successfully finished without error and closed the input stream
already. This change removes the use of try-with-resources, and relies
on the finally block to close the resources once.

Related changes include:

* Remove unnecessary wrapping class to carry the original input stream
  alongside the decrypting wrapper input stream, since the original
  input stream is already available to all callers, and it was only used
  to get the decrypting wrapper input stream. The decrypting input
  stream can now be retrieved directly instead of placing it in a new
  holder object. The method to get the decrypting stream was renamed and
  a javadoc was added to make it easier to understand what it does.
* Change LogHeaderIncompleteException to not be a subclass of
  IOException, so that it can be explicitly caught, and not easily
  overlooked when handling other IOExceptions. Its cause parameter type
  was also narrowed to the EOFException, which is the only valid
  exception to cause the LogHeaderIncompleteException to be thrown.
@ctubbsii ctubbsii self-assigned this Jan 6, 2021
@ctubbsii ctubbsii merged commit 81e36d0 into apache:main Jan 7, 2021
@ctubbsii ctubbsii deleted the fix-error-msg-on-recovery-success branch January 7, 2021 21:43
@ctubbsii ctubbsii added this to the 2.1.0 milestone Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant