public void put(InterceptedStream<T> stream) {

        // Add given stream to map
        InterceptedStream<T> oldStream =
                streams.put(stream.getIndex(), stream);

        // If a previous stream DID exist, close it
        if (oldStream != null)
            close(oldStream.getStream());

    }
Adds the given stream to this map, storing it under its associated
index. If another stream already exists within this map having the same
index, that stream will be closed and replaced.

@param stream
    The stream to store within this map.
guacamole/src/main/java/org/apache/guacamole/tunnel/InterceptedStreamMap.java