Commit Graph

180 Commits

Author SHA1 Message Date
Trustin Lee
b5989e2449 Reduce exception instantiation overhead in SslHandler / Reduce unnecessary empty array creation
- Added EmptyArrays as an internal utility class
2013-04-24 09:32:53 +09:00
Trustin Lee
32fa4c07f3 Do not unwrap a CompositeByteBuf when it is added as a component of another CompositeByteBuf
.. because Reference counting introduces life cycle issues to the CompositeByteBuf being added.

 - Fixes #1266
2013-04-23 21:53:51 +09:00
Norman Maurer
9a5f45a0c1 [#1297] Make sure ResourceLeakDetector.open(...) is only used after constructing was successful 2013-04-22 10:07:22 +02:00
Trustin Lee
8884e311f1 Fix a bug where DefaultCompositeByteBuf.nioBuffers() fails when its component's nioBufferCount() is greater than 1
- Fixes #1267
2013-04-19 04:35:44 +09:00
Trustin Lee
9e890f0ab8 Ensure to release the component when it's removed from CompositeByteBuf / Add tests for reference counting of CompositeByteBuf 2013-04-18 16:40:22 +09:00
Trustin Lee
5bfb408b7d Add setRefCnt(int) method to AbstractReferenceCounted(ByteBuf)
- Fixes #1265
2013-04-11 19:36:27 +09:00
Norman Maurer
3b8673733e [#1262] Respect adjustment when using SlicedByteBuf.nioBuffers() 2013-04-10 14:19:03 +02:00
Norman Maurer
d34daebeca [#1238] Correctly log the content of the MessageBuf and not depend on MessageBuf.toString()
Add an extra static method to BufUtil which will convert the content of any MessaBuf implementation to a String
2013-04-08 09:45:00 +02:00
Trustin Lee
0ac31ae846 Make Unpooled*ByteBuf public so that ByteBufAllocator implementor can extend it 2013-04-04 17:26:14 +09:00
Norman Maurer
94ef7dc1b9 Optimize to minimize volatile reads to access next buffer in codec framework 2013-04-03 18:03:55 +02:00
Trustin Lee
c3559ddbda Fix misleading example in ByteBuf 2013-04-03 22:18:38 +09:00
Trustin Lee
baf9ecfe7b Fix IndexOutOfBoundsException raised when numHeapArenas and numDirectArenas differ
- Fixes #1227
2013-04-03 22:15:34 +09:00
Trustin Lee
8fef511390 Fix typo 2013-04-03 22:08:43 +09:00
Norman Maurer
af4b71a00e Remove special handling of Object[] in codec framework (a.k.a unfolding)
- Fixes #1229
- Primarily written by @normanmaurer and revised by @trustin

This commit removes the notion of unfolding from the codec framework
completely.  Unfolding was introduced in Netty 3.x to work around the
shortcoming of the codec framework where encode() and decode() did not
allow generating multiple messages.

Such a shortcoming can be fixed by changing the signature of encode()
and decode() instead of introducing an obscure workaround like
unfolding.  Therefore, we changed the signature of them in 4.0.

The change is simple, but backward-incompatible.  encode() and decode()
do not return anything.  Instead, the codec framework will pass a
MessageBuf<Object> so encode() and decode() can add the generated
messages into the MessageBuf.
2013-04-03 21:44:54 +09:00
Trustin Lee
2ffa083d3c Allow overriding the default allocator properties and log them / Prettier log 2013-04-03 12:08:01 +09:00
Adam Vandenberg
8e23ab6886 Fix typo in BufType javadoc 2013-03-29 21:47:55 +09:00
Norman Maurer
5a7f049fe2 [#1202] Fix javadoc 2013-03-28 10:01:26 +01:00
Norman Maurer
71727e42de [#1210] Allow to use derived buffers with DefaultBufferHolder and so fix broken SpdySessionHandler 2013-03-27 07:30:12 +01:00
Norman Maurer
f53db96a3e [#1198] Fix references to ChannelBuffer and ChannelBuffers 2013-03-25 11:06:58 +01:00
Norman Maurer
4eb0172251 [#1196] Make it clear that addComponent(..) of CompositeByteBuf does NOT increase the writerIndex 2013-03-25 10:58:50 +01:00
Norman Maurer
f136fb3673 [#1197] Add Unpooled.unreleasableBuffer(...) to create a unreleasable view on a ByteBuf) 2013-03-23 11:25:01 +01:00
Norman Maurer
c71dc9d4b6 [#1195] Fix Unpooled.wrappedBuffer(..) with non-direct read-only ByteBuffer 2013-03-23 10:57:07 +01:00
Trustin Lee
28576aa41e Fix incorrect exception message
- Thanks @hepin1989
2013-03-22 16:07:10 +09:00
Norman Maurer
52c4e042d6 Correctly handle read-only direct ByteBuffer when wrap them 2013-03-22 06:49:57 +09:00
Trustin Lee
0f351d2c47 Fix memory leak in DefaultCompositeByteBuf when a component is another CompositeByteBuf / Allow retain() and release() on a derived buffer 2013-03-14 16:37:20 +09:00
Trustin Lee
60d9984db1 Fix memory leak in DefaultCompositeByteBuf when a component is another CompositeByteBuf 2013-03-14 16:06:38 +09:00
Trustin Lee
b86d3d692a Fix a bug where AbstractByteBuf.order() doesn't return a swapped buffer if capacity is 0.
- Fixes #1152
2013-03-14 06:58:14 +09:00
Trustin Lee
e1dd149ca6 Reschedule the streaming API for later
- Will release as a part of http_next
2013-03-12 13:08:10 +09:00
Trustin Lee
5d65bbc0a9 Add package-info.java for the Stream API / Print maven version on travis CI 2013-03-11 09:09:46 +09:00
Trustin Lee
32efba34d8 Initial implementation of the Streaming API
This pull request provides a framework for exchanging a very large
stream between handlers, typically between a decoder and an inbound
handler (or between a handler that writes a message and an encoder that
encodes that message).

For example, an HTTP decoder, previously, generates multiple
micro-messages to decode an HTTP message (i.e. HttpRequest +
HttpChunks). With the streaming API, The HTTP decoder can simply
generate a single HTTP message whose content is a Stream. And then the
inbound handler can consume the Stream via the buffer you created when
you begin to read the stream. If you create a buffer whose capacity is
bounded, you can handle a very large stream without allocating a lot of
memory. If you just want to wait until the whole content is ready, you
can also do that with an unbounded buffer.

The streaming API also supports a limited form of communication between
a producer (i.e. decoder) and a consumer. A producer can abort the
stream if the stream is not valid anymore. A consumer can choose to
reject or discard the stream, where rejection is for unrecoverable
failure and discard is for recoverable failure.

P.S. Special thanks to @jpinner for the initial input.
2013-03-11 08:57:17 +09:00
Norman Maurer
0a1bc86569 Javadocs cleanup / added 2013-03-10 21:07:19 +01:00
Norman Maurer
0ac5fd9f18 Let BufUtil.retain(...) return the given object 2013-03-10 19:50:26 +01:00
Trustin Lee
63116239ac Always use EmptyByteBuf when a user attempts to construct a buffer with 0 maxCapacity / Make EmptyByteBuf remember the allocator it came from / Optimize EmptyByteBuf a little bit 2013-03-08 11:03:11 +09:00
Trustin Lee
096e4c95ef Fix checkstyle 2013-03-08 10:39:52 +09:00
Trustin Lee
12f1d96914 Relaxed memory access constraint of ReferenceCounted.refCnt() for potentially better performance / More precise reference counting for MessageBuf 2013-03-08 10:32:20 +09:00
Trustin Lee
303f83043b Fix checkstyle 2013-03-06 18:23:08 +09:00
Trustin Lee
88df53ec1a Fix infinite recursion when transferring data between different type of buffers / Add ByteBuf.hasMemoryAddress/memoryAddress()
- Fixes: #1109 and #1110
2013-03-06 18:22:16 +09:00
Trustin Lee
3d6d9f394d Fix checkstyle 2013-03-06 17:10:26 +09:00
Trustin Lee
81ce0555e6 Add UnpooledUnsafeDirectByteBuf and use it when low-level access is available
- Remove PooledUnsafeDirectByteBuf.setMedium() which is redundant
- Fix constructor visibility
2013-03-06 16:01:46 +09:00
Trustin Lee
6c3d5ed907 Use _set* in AbstractByteBuf.write*() 2013-03-06 14:56:27 +09:00
Trustin Lee
1c1570ffc4 Make field access via ByteBuf.read/write*() faster by avoiding unnecessary boundary checks
- also disabled a time consuming test that is actually a regression test
2013-03-06 10:32:29 +09:00
Trustin Lee
5f2c2cdc9b Fix a bug in PoolArena and PoolSubpage where subpage pools are not updated correctly
- Make PoolSubpage a linked list node in the pool
- Now that a subpage is added to and removed from the pool correctly, allocating a subpage from the pool became vastly simpler.
2013-03-05 23:55:41 +09:00
Trustin Lee
4cb023f190 Add more variants of ByteBufAllocator.ioBuffer() / Update Javadoc 2013-03-05 17:59:31 +09:00
Trustin Lee
8d88acb4a7 Change ByteBufAllocator.buffer() to allocate a direct buffer only when the platform can handle a direct buffer reliably
- Rename directbyDefault to preferDirect
 - Add a system property 'io.netty.prederDirect' to allow a user from changing the preference on launch-time
 - Merge UnpooledByteBufAllocator.DEFAULT_BY_* to DEFAULT
2013-03-05 17:55:24 +09:00
Trustin Lee
307e6c47d8 Make hasUnsafe() return true only when all necessary low level operations are available for reliable direct buffer access 2013-03-05 17:25:54 +09:00
Trustin Lee
7e17f71b30 Make PlatformDependent work with the platforms without unaligned access support 2013-03-05 14:27:52 +09:00
Trustin Lee
d4d01ba52c Optimize SlicedByteBuf a little bit 2013-02-27 15:19:25 -08:00
Trustin Lee
a9a8d5d8c2 Clean-up 2013-02-21 14:17:04 -08:00
Norman Maurer
74738fbd08 [#1061] Add workaround to not use PooledUnsafeDirectByteBuf when running on latest OpenJDK6 because of missing Unsafe method 2013-02-19 12:21:08 +01:00
Norman Maurer
4ed5b07e4e [#1060] Fix bug in CompositeByteBuf which let the buffer expand in a incorrect way and so result in corrupted data 2013-02-19 09:43:31 +01:00