This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-settings.git
The following commit(s) were added to refs/heads/master by this push:
new b8fa531 trivial: switch to try with resources
b8fa531 is described below
commit b8fa5314f9b13e9fcf1b8f8f56ab0812fce2f5e5
Author: Konrad Windszus <[email protected]>
AuthorDate: Tue Jun 30 17:19:08 2020 +0200
trivial: switch to try with resources
---
.../impl/SlingSettingsServiceImplTest.java | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git
a/src/test/java/org/apache/sling/settings/impl/SlingSettingsServiceImplTest.java
b/src/test/java/org/apache/sling/settings/impl/SlingSettingsServiceImplTest.java
index 4e7b8c0..15c935f 100644
---
a/src/test/java/org/apache/sling/settings/impl/SlingSettingsServiceImplTest.java
+++
b/src/test/java/org/apache/sling/settings/impl/SlingSettingsServiceImplTest.java
@@ -126,29 +126,11 @@ public class SlingSettingsServiceImplTest {
when(context.getDataFile(OPTIONS_FILE_NAME)).thenReturn(optionsFile);
// write options
final List<SlingSettingsServiceImpl.Options> options = new
ArrayList<SlingSettingsServiceImpl.Options>();
- FileOutputStream fos = null;
- ObjectOutputStream oos = null;
- try {
- fos = new FileOutputStream(optionsFile);
- oos = new ObjectOutputStream(fos);
+ try (FileOutputStream fos = new FileOutputStream(optionsFile);
+ ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(options);
} catch (final IOException ioe) {
throw new RuntimeException("Unable to write to options data
file.", ioe);
- } finally {
- if (oos != null) {
- try {
- oos.close();
- } catch (IOException ignore) {
- // ...
- }
- }
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException ignore) {
- // ...
- }
- }
}
return new SlingSettingsServiceImpl(context);
}