Skip to content

Fix #510: Propagate IOException instead of swallowing it in ApplicationXmlWriter.write()#523

Open
elharo wants to merge 1 commit into
apache:masterfrom
elharo:fix/issue-510
Open

Fix #510: Propagate IOException instead of swallowing it in ApplicationXmlWriter.write()#523
elharo wants to merge 1 commit into
apache:masterfrom
elharo:fix/issue-510

Conversation

@elharo

@elharo elharo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes #510

Problem

In ApplicationXmlWriter.write(), any IOException during XML writing (e.g., disk full, permission denied) is silently swallowed:

```java
} catch (IOException ex) {
// ignore
}
```

This means the EAR build succeeds with a truncated or missing application.xml deployment descriptor, making the failure undetectable.

Changes

  1. ApplicationXmlWriter.java: Replace the empty catch block with a throw of EarPluginException wrapping the IOException.
  2. ApplicationXmlWriterTest.java (new): Unit tests for the writer:
    • testWriteSucceedsToValidFile: happy path writing to a temp file
    • testWriteThrowsExceptionOnIoError: writing to /dev/full asserts EarPluginException is thrown

Verification

  • Test-first: the new test failed before the fix (exception was silently swallowed)
  • After fix: all 45 tests pass

…licationXmlWriter.write()

Replace the empty catch block with a throw of EarPluginException wrapping
the IOException, so build fails on IO errors instead of silently
producing a truncated or missing application.xml.

Adds unit test coverage for ApplicationXmlWriter:
- Happy path: write to a valid temp file
- Failure path: write to /dev/full triggers EarPluginException
@elharo elharo requested a review from eolivelli July 3, 2026 15:04
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.

IOException silently swallowed in ApplicationXmlWriter.write()

1 participant