Source:
<code>public long compress(InputStream is, OutputStream os, long maxReadLength, long maxWriteLength, final long amountOfDataToCheckCompressionRatio, final int minimumCompressionPercentage) throws IOException, CompressionRatioException { if (amountOfDataToCheckCompressionRatio == Long.MAX_VALUE && minimumCompressionPercentage == 0) { <START> return compress(is, os, maxReadLength, maxWriteLength); <END> } CountedInputStream cis = null; CountedOutputStream cos = null; cis = new CountedInputStream(is); cos = new CountedOutputStream(os); Encoder encoder = new Encoder(); encoder.SetEndMarkerMode( true ); int dictionarySize = 1; if(maxReadLength == Long.MAX_VALUE || maxReadLength < 0) { dictionarySize = MAX_DICTIONARY_SIZE; Logger.error(this, "No indication of size, having to use maximum dictionary size", new Exception("debug")); } else { while(dictionarySize < maxReadLength && dictionarySize < MAX_DICTIONARY_SIZE) dictionarySize <<= 1; } encoder.SetDictionarySize( dictionarySize ); encoder.WriteCoderProperties(os); try { encoder.Code(cis, cos, maxReadLength, maxWriteLength, new ICodeProgress() { boolean compressionEffectNotChecked = true; @Override public void SetProgress(long processedInSize, long processedOutSize) { if (compressionEffectNotChecked && processedInSize > amountOfDataToCheckCompressionRatio) { try { checkCompressionEffect( processedInSize, processedOutSize, minimumCompressionPercentage); } catch (CompressionRatioException e) { throw new CompressionRatioRuntimeException(e); } compressionEffectNotChecked = false; } } }); } catch (CompressionRatioRuntimeException e) { throw (CompressionRatioException) e.getCause(); } if(cos.written() > maxWriteLength) throw new CompressionOutputSizeException(cos.written()); cos.flush(); if(logMINOR) Logger.minor(this, "Read "+cis.count()+" written "+cos.written()); return cos.written(); }</code><technical_language>This is changing behaviour of encoder (dictionary, end-marking, ...)... do need this</technical_language>

Target:
public long compress(InputStream is, OutputStream os, long maxReadLength, long maxWriteLength, final long amountOfDataToCheckCompressionRatio, final int minimumCompressionPercentage) throws IOException, CompressionRatioException { CountedInputStream cis = null; CountedOutputStream cos = null; cis = new CountedInputStream(is); cos = new CountedOutputStream(os); Encoder encoder = new Encoder(); encoder.SetEndMarkerMode( true ); int dictionarySize = 1; if(maxReadLength == Long.MAX_VALUE || maxReadLength < 0) { dictionarySize = MAX_DICTIONARY_SIZE; Logger.error(this, "No indication of size, having to use maximum dictionary size", new Exception("debug")); } else { while(dictionarySize < maxReadLength && dictionarySize < MAX_DICTIONARY_SIZE) dictionarySize <<= 1; } encoder.SetDictionarySize( dictionarySize ); encoder.WriteCoderProperties(os); try { encoder.Code(cis, cos, maxReadLength, maxWriteLength, new ICodeProgress() { boolean compressionEffectShouldBeChecked = minimumCompressionPercentage != 0; @Override public void SetProgress(long processedInSize, long processedOutSize) { if (compressionEffectShouldBeChecked && processedInSize > amountOfDataToCheckCompressionRatio) { try { checkCompressionEffect(processedInSize, processedOutSize, minimumCompressionPercentage); } catch (CompressionRatioException e) { throw new RuntimeException(e); } compressionEffectShouldBeChecked = false; } } }); } catch (RuntimeException e) { if (e.getCause() instanceof CompressionRatioException) { throw (CompressionRatioException) e.getCause(); } else { throw e; } } if(cos.written() > maxWriteLength) throw new CompressionOutputSizeException(cos.written()); cos.flush(); if(logMINOR) Logger.minor(this, "Read "+cis.count()+" written "+cos.written()); return cos.written(); }