Skip to content

Commit

Permalink
Remove ThreadLocal for ByteArrayOutputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
komamitsu committed Aug 27, 2016
1 parent f058462 commit 18fb2bd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions src/main/java/org/komamitsu/fluency/buffer/Buffer.java
Expand Up @@ -23,13 +23,6 @@ public abstract class Buffer<T extends Buffer.Config>
protected static final Charset CHARSET = Charset.forName("ASCII");
protected final T bufferConfig;
protected final ObjectMapper objectMapper;
protected final ThreadLocal<ByteArrayOutputStream> outputStreamHolder = new ThreadLocal<ByteArrayOutputStream>() {
@Override
protected ByteArrayOutputStream initialValue()
{
return new ByteArrayOutputStream();
}
};
protected final FileBackup fileBackup;

public Buffer(final T bufferConfig)
Expand Down
Expand Up @@ -135,7 +135,7 @@ protected void saveAllBuffersToFile()
public void append(String tag, long timestamp, Map<String, Object> data)
throws IOException
{
ByteArrayOutputStream outputStream = outputStreamHolder.get();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.reset();
objectMapper.writeValue(outputStream, Arrays.asList(timestamp, data));
outputStream.close();
Expand Down

0 comments on commit 18fb2bd

Please sign in to comment.