code: public static ByteBuf wrappedBuffer(ByteBuf buffer) {
          if (buffer.isReadable()) {
              return buffer.slice();
          } else {
              buffer.release();
              return EMPTY_BUFFER;
          }
      }
docs: Creates a new buffer which wraps the specified buffer's readable bytes.
  A modification on the specified buffer's content will be visible to the
  returned buffer.
  @param buffer The buffer to wrap. Reference count ownership of this variable is transferred to this method.
  @return The readable portion of the {@code buffer}, or an empty buffer if there is no readable portion.
  The caller is responsible for releasing this buffer.