Over a million developers have joined DZone.

New Interfaces For MultiMap and MultiSet in Apache Commons Collections 4.1

Apache Commons Collections is a project for the development and maintenance of collection classes extending the JDK collection framework. Version 4.1 just arrived.

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

The Apache Commons Collections project just released version 4.1, which has a few interesting new features despite being labelled a minor security release.  Let's take a look at the major new features since 4.0:

  • Added new interfaces "MultiValuedMap", "ListValuedMap" and "SetValuedMap" as a replacement for "MultiMap". Decorators and implementations reside in the "multimap" package and a "MultiMapUtils" class has been added. The existing interface "MultiMap" as well as the concrete implementation "MultiValueMap" has been deprecated. Fixes COLLECTIONS-508.

  • Added new MultiSet interface which is intended to be a replacement for the Bag interface. The main difference is that a MultiSet is fully compatible to the Collection contract. Fixes COLLECTIONS-567.

  • Added new class "FluentIterable" to support a fluent API for manipulating Iterable instances. Additionally various supporting methods have been added to "IterableUtils" and "IteratorUtils". Fixes COLLECTIONS-464,COLLECTIONS-442.

There's also a full list of the changes here.  4.x is also the first line to require Java 6+. The source and binary are compatible with the  4.0 release of Commons Collections with the exception that some classes in the functor package do not implement the Serializable interface anymore. This is because serialization support for unsafe classes in the functor package "has been removed completely as this can be exploited for remote code execution attacks. Classes considered to be unsafe are: CloneTransformer, ForClosure, InstantiateFactory, InstantiateTransformer, InvokerTransformer, PrototypeCloneFactory, PrototypeSerializationFactory, WhileClosure."

If you use Commons Collections, the security fix is probably the biggest reason to upgrade.

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

java ,apache commons

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}