What is the desired thread safety of the CompressionStrategy class? From looking at it from an API perspective, it looks to be you:
Allocate input buffer, Allocate output buffer, compress / decompress. The CompressionStrategyTest.testConcurrency() test if you bump the number of threads to 100, and run it a few times, you will see there are race conditions which will cause failures. The quick and easy solution to make this thread safe is to synchronize the methods. But in reality it looks like this class is mainly used to compress, decompress segments so that will be a a thread / segment which is okay. My question is I am confused as to what should be the behavior, should it be thread safe and a generic api to compress / decompress. If so then we should fix the code in Compression Strategy to be thread safe, if not then maybe remove that test and mark the class as NotThreadSafe. Was wondering about other people's thoughts. Thanks