Skip to content

Commit

Permalink
release at fromPath level instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Maldini committed Oct 13, 2017
1 parent 39a6383 commit f34df23
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/test/java/reactor/ipc/netty/ByteBufFluxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package reactor.ipc.netty;

import io.netty.buffer.ByteBuf;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Iterator;

import io.netty.buffer.ByteBuf;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

/**
* Unit tests for {@link ByteBufFlux}
*
Expand Down Expand Up @@ -58,12 +58,16 @@ public void testFromPath() throws Exception {
Assert.assertEquals(data.length, Files.size(tmpFile));

// Use the ByteBufFlux to read the file in chunks of 3 bytes max and write them into a ByteArrayOutputStream for verification
final Iterator<ByteBuf> it = ByteBufFlux.fromPath(tmpFile, chunkSize).toIterable().iterator();
final Iterator<ByteBuf> it = ByteBufFlux.fromPath(tmpFile, chunkSize)
.retain()
.toIterable()
.iterator();
final ByteArrayOutputStream out = new ByteArrayOutputStream();
while (it.hasNext()) {
ByteBuf bb = it.next();
byte[] read = new byte[bb.readableBytes()];
bb.readBytes(read);
bb.release();
Assert.assertEquals(0, bb.readableBytes());
out.write(read);
}
Expand Down

0 comments on commit f34df23

Please sign in to comment.