Skip to content

Prevent resource leak #1415

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

Merged
merged 5 commits into from
Apr 11, 2023
Merged

Prevent resource leak #1415

merged 5 commits into from
Apr 11, 2023

Conversation

mernst
Copy link
Contributor

@mernst mernst commented Apr 8, 2023

In CommonsCompressAction.execute(), if an exception occurs during the call to new BufferedOutputStream or createCompressorOutputStream, then the FileOutputStream is never closed and a resource leak occurs. This patch refactors the code so that the FileOutputStream is always closed.

@vy vy self-assigned this Apr 10, 2023
@mernst
Copy link
Contributor Author

mernst commented Apr 10, 2023

@vy Thanks for the suggestions

@vy vy merged commit d33bc3c into apache:2.x Apr 11, 2023
@vy
Copy link
Member

vy commented Apr 11, 2023

Thanks so much for the contributions @mernst, much appreciated! 😍

@mernst mernst deleted the close-resource branch April 11, 2023 17:08
rgoers added a commit that referenced this pull request May 16, 2023
* Interim commit

* More fixes

* Everything builds

* Fix `PatternLayout.Builder#withHeader()` javadoc (#1411)

* Fix `SimpleDateFormat`-related JDK bug URL in `FastDateParser` javadoc (#1404)

* Ensure `FileOutputStream` is closed in `CommonsCompressAction.execute()` (#1415)

* Fix nullability docs in `StrSubstitutor` (#1422)

* Change `{@literal null}` to `{@code null}` (#1424)

* Remove deprecated docs from `PatternParser#extractConverter()` (#1423)

* Bump actions/checkout from 3.4.0 to 3.5.2 (#1434)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3.4.0 to 3.5.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@24cb908...8e5e7e5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.3.0 to 4.6.0 (#1440)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.3.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@13ae5bb...57ded4d)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* LOG4J2-3660 Fix `%notEmpty` for empty MDC/NDC inputs

* LOG4J2-3660 Add `MdcPatternConverter` fixes missing from the cherry-pick

* Prepare for formatting of all files

Sometimes Spotless will not detect that a header already exists, e.g. if
it is after a package declaration.

* Apply Spotless

* Bump github/codeql-action from 2.1.28 to 2.3.1 (#1452)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.28 to 2.3.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@cc7986c...8662eab)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github/codeql-action from 2.3.1 to 2.3.2 (#1455)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.1 to 2.3.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@8662eab...f3feb00)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add Log4j Transform documentation

Adds a documentation page that forwards the user to Github.

* Fix license header

* Fix typo in `SECURITY.md` (#1457)

* Bump logging-parent from 8 to 9

By bumping to logging-parent 9, we remove the explicit Spotless
configuration.

* Rebase with main

* Trying to rebase from main

* Provide LoggerContext properties during configuration

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Michael Ernst <[email protected]>
Co-authored-by: Michael Ernst <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Volkan Yazıcı <[email protected]>
Co-authored-by: Piotr P. Karwasz <[email protected]>
Co-authored-by: spotless[bot] <[email protected]>
Co-authored-by: Michael Scovetta <[email protected]>
theit pushed a commit to theit/logging-log4j2 that referenced this pull request May 30, 2023
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.

2 participants