garydgregory commented on a change in pull request #108: Refactor ByteArrayOutputStream into synchronized and non-synchronized versions URL: https://github.com/apache/commons-io/pull/108#discussion_r403321265
########## File path: src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java ########## @@ -0,0 +1,391 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.io.output; + +import org.apache.commons.io.input.ClosedInputStream; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.SequenceInputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.apache.commons.io.IOUtils.EOF; + +/** + * This is the base class for implementing an output stream in which the data + * is written into a byte array. The buffer automatically grows as data + * is written to it. + * <p> + * The data can be retrieved using <code>toByteArray()</code> and + * <code>toString()</code>. + * <p> + * Closing an {@code AbstractByteArrayOutputStream} has no effect. The methods in + * this class can be called after the stream has been closed without + * generating an {@code IOException}. + * <p> + * This is the base for an alternative implementation of the + * {@link java.io.ByteArrayOutputStream} class. The original implementation + * only allocates 32 bytes at the beginning. As this class is designed for + * heavy duty it starts at 1024 bytes. In contrast to the original it doesn't + * reallocate the whole memory block but allocates additional buffers. This + * way no buffers need to be garbage collected and the contents don't have + * to be copied to the new buffer. This class is designed to behave exactly + * like the original. The only exception is the deprecated + * {@link java.io.ByteArrayOutputStream#toString(int)} method that has been + * ignored. + */ Review comment: Please Add `@since 2.7`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
