2016-10-11
- Fix: The four-argument overload of
Buffer.writeString()
had a major bug where it didn't respect offsets if the specified charset was UTF-8. This was because our short-circuit optimization omitted necessary offset parameters. - New: HMAC support in
HashingSource
,HashingSink
,ByteString
, andBuffer
. This makes it easy to create a keyed-hash message authentication code (HMAC) wherever your data is. Unlike the other hashes, HMAC uses aByteString
secret key for authentication. - New:
ByteString.of(ByteBuffer)
makes it easier to mix NIO with Okio.
2016-08-28
- Fix: Support reading files larger than 2 GiB with
GzipSource
. Previously attempting to decompress such files would fail due to an overflow when validating the total length. - Fix: Exit the watchdog thread after being idle for 60 seconds. This should make it possible for class unloaders to fully unload Okio.
- New:
Okio.blackhole()
returns a sink where all bytes written are discarded. This is Okio's equivalent of/dev/null
. - New: Encode a string with any charset using
ByteString.encodeString()
and decode strings in any charset usingByteString.string()
. Most applications should preferByteString.encodeUtf8()
andByteString.utf8()
unless it's necessary to support a legacy charset. - New:
GzipSink.deflater()
makes it possible to configure the compression level.
2016-07-01
- New:
Pipe
makes it easy to connect a producer thread to a consumer thread. Reads block until data is available to read. Writes block if the pipe's is full. Both sources and sinks support timeouts. - New:
BufferedSource.rangeEquals()
makes it easy to compare a range in a stream to an expected value. This does the right thing: it blocks to load the data required return a definitive result. But it won't block unnecessarily. - New:
Timeout.waitUntilNotified()
makes it possible to use nice timeout abstractions on Java's built-in wait/notify primitives. - Fix: Don't return incorrect results when
HashingSource
does large reads. There was a bug where it wasn't traversing through the segments of the buffer being hashed. This means thatHashingSource
was returning incorrect answers for any writes that spanned multiple segment boundaries.
2016-05-02
- New:
BufferedSource.select(Options)
API for reading one of a set of expected values. - New: Make
ByteString.toString()
andBuffer.toString()
friendlier. These methods return text if the byte string is valid UTF-8. - New: APIs to match byte strings:
indexOf()
,startsWith()
, andendsWith()
.
2016-04-10
- New: Change the segment size to 8 KiB. This has been reported to dramatically improve performance in some applications.
- New:
md5()
,sha1()
, andsha256()
methods onBuffer
. Also add asha1()
method onByteString
for symmetry. - New:
HashingSource
andHashingSink
. These classes are Okio’s equivalent to the JDK’sDigestInputStream
andDigestOutputStream
. They offer convenientmd5()
,sha1()
, andsha256()
factory methods to avoid an impossibleNoSuchAlgorithmException
. - New:
ByteString.asByteBuffer()
. - Fix: Limit snapshot byte strings to requested size.
- Fix: Change write timeouts to have a maximum write size. Previously large writes could easly suffer timeouts because the entire write was subject to a single timeout.
- Fix: Recover from EBADF failures, which could be triggered by asynchronously closing a stream on older versions of Android.
- Fix: Don't share segments if doing so only saves a small copy. This should improve performance for all applications.
- Fix: Optimize
BufferedSource.indexOfElement()
andindexOf(ByteString)
. Previously this method had a bug that caused it to be very slow on large buffers.
2015-08-25
- New:
BufferedSource.indexOf(ByteString)
searches a source for the next occurrence of a byte string. - Fix: Recover from unexpected
AssertionError
thrown on Android 4.2.2 and earlier when asynchronously closing a socket.
2015-06-19
- Sockets streams now throw
SocketTimeoutException
. This builds on new extension point inAsyncTimeout
to customize the exception when a timeout occurs. - New:
ByteString
now implementsComparable
. The comparison sorts bytes as unsigned: {@code ff} sorts after {@code 00}.
2015-05-16
- Timeout exception changed. Previously
Timeout.throwIfReached()
would throwInterruptedIOException
on thread interruption, andIOException
if the deadline was reached. Now it throwsInterruptedIOException
in both cases. - Fix: throw
EOFException
when attempting to read digits from an empty source. Previously this would crash with an unchecked exception. - New: APIs to read and write UTF-8 code points without allocating strings.
- New:
BufferedSink
can now write substrings directly, potentially saving an allocation for some callers. - New:
ForwardingTimeout
class.
2015-03-16
- New: Read and write signed decimal and unsigned hexadecimal values in
BufferedSource
andBufferedSink
. Unlike the alternatives, these methods don’t do any memory allocations! - New: Segment sharing. This improves the runtime of operations like
Buffer.clone()
andBuffer.copyTo()
by sharing underlying segments between buffers. - New:
Buffer.snapshot()
returns an immutable snapshot of a buffer as aByteString
. This builds on segment sharing so that snapshots are shallow, immutable copies. - New:
ByteString.rangeEquals()
. - New:
ByteString.md5()
andByteString.sha256()
. - New:
ByteString.base64Url()
returns URL-safe Base64. The existing decoding method has been extended to support URL-safe Base64 input. - New:
ByteString.substring()
returns a prefix, infix, or suffix. - New:
Sink
now implementsjava.io.Flushable
. - Fix:
Buffer.write(Source, long)
now always writes fully. The previous behavior would return as soon as any data had been written; this was inconsistent with all other write() methods in the API. - Fix: don't leak empty segments in DeflaterSink and InflaterSource. (This was unlikely to cause problems in practice.)
2014-12-30
- Fix:
Okio.buffer()
always buffers for better predictability. - Fix: Provide context when
readUtf8LineStrict()
throws. - Fix: Buffers do not call through the
Source
on zero-byte writes.
2014-12-11
- Do UTF-8 encoding natively for a performance increase, particularly on Android.
- New APIs:
BufferedSink.emit()
,BufferedSource.request()
andBufferedSink.indexOfElement()
. - Fixed a performance bug in
Buffer.indexOf()
2014-08-08
- Added
read(byte[])
,read(byte[], offset, byteCount)
, andvoid readFully(byte[])
toBufferedSource
. - Refined declared checked exceptions on
Buffer
methods.
2014-05-23
- Bumped release version. No other changes!
2014-05-03
- Use 0 as a sentinel for no timeout.
- Make AsyncTimeout public.
- Remove checked exception from Buffer.readByteArray.
2014-04-24
- Eagerly verify preconditions on public APIs.
- Quick return on Buffer instance equivalence.
- Add delegate types for Sink and Source.
- Small changes to the way deadlines are managed.
- Add append variant of Okio.sink for File.
- Methods to exhaust BufferedSource to byte[] and ByteString.
2014-04-18
- Don't use getters in timeout.
- Use the watchdog to interrupt sockets that have reached deadlines.
- Add java.io and java.nio file source/sink helpers.
2014-04-17
- Methods to read a buffered source fully in UTF-8 or supplied charset.
- API to read a byte[] directly.
- New methods to move all data from a source to a sink.
- Fix a bug on input stream exhaustion.
2014-04-15
- Make ByteString serializable.
- New API:
ByteString.of(byte[] data, int offset, int byteCount)
- New API: stream-based copy, write, and read helpers.
2014-04-08
- Initial public release.
- Imported from OkHttp.