This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
mvn compile # Compile
mvn test # Run all tests with coverage
mvn package # Build JAR
mvn install -Dgpg.skip=true # Install to local repo without GPG signingRun a single test:
mvn test -Dtest=StreamBufferTest#testSimpleRoundTripRun mutation tests:
mvn org.pitest:pitest-maven:mutationCoverageStreamBuffer is a single-class Java library (net.ladenthin.streambuffer) that connects an OutputStream and InputStream through a dynamic FIFO queue — solving the fixed-buffer and cross-thread-deadlock limitations of Java's PipedInputStream/PipedOutputStream.
src/main/java/net/ladenthin/streambuffer/StreamBuffer.java
- Implements
Closeable - Internal FIFO:
Deque<byte[]>(stores byte array references, not copies) - Exposes
getInputStream()→SBInputStream extends InputStream - Exposes
getOutputStream()→SBOutputStream extends OutputStream
bufferLockobject — synchronizes all deque accessvolatilefields —streamClosed,safeWrite,availableBytes,positionAtCurrentBufferEntry,maxBufferElementsSemaphore signalModification— blocks reading threads until data is written or stream is closed (avoids busy-waiting)
positionAtCurrentBufferEntry— tracks read offset within the head byte array, enabling partial reads without copyingsafeWrite(default:false) — whentrue, clones input arrays on write to protect against external mutation- Buffer trimming — when
Dequesize exceedsmaxBufferElements(default: 100), all buffered data is consolidated into a single byte array;isTrimShouldBeExecuted()controls this available()returnsInteger.MAX_VALUEwhenavailableBytes > Integer.MAX_VALUE, supporting >2GB buffers
src/test/java/net/ladenthin/streambuffer/StreamBufferTest.java uses JUnit 4 with DataProviderRunner. Most tests are parameterized across 3 write variants (ByteArray, Int, ByteArrayWithParameter) defined in WriteMethod.java.