Project icon

com.io7m.jmulticlose

Build status Maven Central Codecov

The jmulticlose package implements a simple extension to the Java try-with-resources statement that allows for closing many resources at once - without nested or compound statements - in a type-safe manner.

Five-second Tutorial

Create a CloseableCollection to track resources. Add resources to it. The resources will be closed when the collection is closed. All resources will be closed even if any of the individual resources raises an exception.

  final Resource r0;
  final Resource r1;
  final Resource r2;

  try (CloseableCollectionType<ClosingResourceFailedException> c = CloseableCollection.create()) {
    r0 = c.add(new Resource(0));
    r1 = c.add(new Resource(1));
    r2 = c.add(new Resource(2));
  }
     

Contents

Features

  • Close multiple resources at once without nested scopes and without a loss of type-safety.
  • OSGi-ready
  • JPMS-ready
  • ISC license
  • 100% automated unit test coverage.

Releases

The most recently published version of the software is 1.1.3.

Source code and binaries are available from the repository.

Documentation

Documentation for the 1.1.3 release is available for reading online.

Documentation for current and older releases is archived in the repository.

User documentation

No user documentation is currently available.

Maven

The following is a complete list of the project's modules expressed as Maven dependencies:

<dependency>
  <groupId>com.io7m.jmulticlose</groupId>
  <artifactId>com.io7m.jmulticlose</artifactId>
  <version>1.1.3</version>
</dependency>

<dependency>
  <groupId>com.io7m.jmulticlose</groupId>
  <artifactId>com.io7m.jmulticlose.core</artifactId>
  <version>1.1.3</version>
</dependency>

<dependency>
  <groupId>com.io7m.jmulticlose</groupId>
  <artifactId>com.io7m.jmulticlose.tests</artifactId>
  <version>1.1.3</version>
</dependency>

Each release of the project is made available on Maven Central within ten minutes of the release announcement.

Changes

Subscribe to the releases atom feed.

2024-05-10 Release: com.io7m.jmulticlose 1.1.3
2024-04-19 Change: Update ch.qos.logback:logback-classic:1.5.3 → 1.5.6.
2024-05-10 Change: Move to new organization.
2024-05-10 Change: Update com.io7m.jcip:com.io7m.jcip.annotations 2.0.0 → 2.0.1.
2024-03-11 Release: com.io7m.jmulticlose 1.1.2
2024-03-11 Change: Adjust contract of CloseableCollection.add()
2024-03-11 Release: com.io7m.jmulticlose 1.1.1
2024-03-11 Change: Fix a minor thread safety issue. (tickets: 2 )
2023-08-13 Release: com.io7m.jmulticlose 1.1.0
2023-08-13 Change: Update ch.qos.logback:logback-classic 1.4.7 → 1.4.11.
2023-08-13 Change: Update org.junit.jupiter:junit-jupiter-engine 5.9.3 → 5.10.0.
2023-08-13 Change: Collections are now thread-safe.
2023-08-13 Change: Add CloseableTracker.
2023-08-13 Change: Expose collection sizes.
2022-04-19 Release: com.io7m.jmulticlose 1.0.0
2022-04-19 Change: Initial public release
2018-07-07 Release: com.io7m.jmulticlose 0.0.1
2018-07-07 Change: Initial release

Sources

This project uses Git to manage source code.

Repository: https://www.github.com/io7m-com/jmulticlose

$ git clone https://www.github.com/io7m-com/jmulticlose

License

Copyright © 2024 Mark Raynsford <code@io7m.com> https://www.io7m.com

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

Bug Tracker

The project uses GitHub Issues to track issues.