/** * Decompress and deserialize content of column FILE_SOURCES.BINARY_DATA. * The parameter "input" is always closed by this method. */ public static List<DbFileSources.Test> decodeTestData(InputStream binaryInput) { LZ4BlockInputStream lz4Input = null; List<DbFileSources.Test> tests = new ArrayList<>(); try { lz4Input = new LZ4BlockInputStream(binaryInput); DbFileSources.Test currentTest; do { currentTest = DbFileSources.Test.parseDelimitedFrom(lz4Input); if (currentTest != null) { tests.add(currentTest); } } while (currentTest != null); return tests; } catch (IOException e) { throw new IllegalStateException("Fail to decompress and deserialize source data", e); } finally { IOUtils.closeQuietly(lz4Input); } }