ronantakizawa/codereview-bench huggingface dataset:
Repository: neovim/neovim
File: src/nvim/highlight_defs.h (C/C++)

Code before:

#include "nvim/api/private/defs.h"

typedef int32_t RgbValue;

/// Highlighting attribute bits.
///
/// sign bit should not be used here, as it identifies invalid highlight
typedef enum {
  HL_INVERSE         = 0x01,
  HL_BOLD            = 0x02,
  HL_ITALIC          = 0x04,
  // The next three bits are all underline styles
  HL_UNDERLINE_MASK  = 0x38,
  HL_UNDERLINE       = 0x08,
  HL_UNDERCURL       = 0x10,
  HL_UNDERDOUBLE     = 0x18,
  HL_UNDERDOTTED     = 0x20,
  HL_UNDERDASHED     = 0x28,
  // 0x30 and 0x38 spare for underline styles
  HL_STANDOUT      = 0x0040,
  HL_STRIKETHROUGH = 0x0080,
  HL_ALTFONT       = 0x0100,
  // 0x0200 spare
  HL_NOCOMBINE     = 0x0400,
  HL_BG_INDEXED    = 0x0800,
  HL_FG_INDEXED    = 0x1000,
  HL_DEFAULT       = 0x2000,
  HL_GLOBAL        = 0x4000,
} HlAttrFlags;

/// Stores a complete highlighting entry, including colors and attributes
/// for both TUI and GUI.
typedef struct {
  int16_t rgb_ae_attr, cterm_ae_attr;  ///< HlAttrFlags
  RgbValue rgb_fg_color, rgb_bg_color, rgb_sp_color;
  int16_t cterm_fg_color, cterm_bg_color;
  int32_t hl_blend;
  int32_t url;
} HlAttrs;

#define HLATTRS_INIT (HlAttrs) { \
  .rgb_ae_attr = 0, \
  .cterm_ae_attr = 0, \
  .rgb_fg_color = -1, \
  .rgb_bg_color = -1, \
  .rgb_sp_color = -1, \
  .cterm_fg_color = 0, \
  .cterm_bg_color = 0, \
  .hl_blend = -1, \
  .url = -1, \

Review comment (suggestion):
> The C flag is named HL_CONCEALED to avoid colliding with the existing HL_CONCEAL in syntax.h (which is a syntax group flag, not an SGR attribute).

Thanks for calling that out. We should call that out in a source code comment too. I will do so in the "docs" PR, to avoid blocking this one.

Code after:

#include "nvim/api/private/defs.h"

typedef int32_t RgbValue;

/// Highlighting attribute bits.
///
/// sign bit should not be used here, as it identifies invalid highlight
typedef enum {
  HL_INVERSE         = 0x01,
  HL_BOLD            = 0x02,
  HL_ITALIC          = 0x04,
  // The next three bits are all underline styles
  HL_UNDERLINE_MASK  = 0x38,
  HL_UNDERLINE       = 0x08,
  HL_UNDERCURL       = 0x10,
  HL_UNDERDOUBLE     = 0x18,
  HL_UNDERDOTTED     = 0x20,
  HL_UNDERDASHED     = 0x28,
  // 0x30 and 0x38 spare for underline styles
  HL_STANDOUT      = 0x0040,
  HL_STRIKETHROUGH = 0x0080,
  HL_ALTFONT       = 0x0100,
  HL_DIM           = 0x0200,
  HL_BLINK         = 0x8000,
  HL_CONCEALED     = 0x10000,
  HL_OVERLINE      = 0x20000,
  HL_NOCOMBINE     = 0x0400,
  HL_BG_INDEXED    = 0x0800,
  HL_FG_INDEXED    = 0x1000,
  HL_DEFAULT       = 0x2000,
  HL_GLOBAL        = 0x4000,
} HlAttrFlags;

/// Stores a complete highlighting entry, including colors and attributes
/// for both TUI and GUI.
typedef struct {
  int32_t rgb_ae_attr, cterm_ae_attr;  ///< HlAttrFlags
  RgbValue rgb_fg_color, rgb_bg_color, rgb_sp_color;
  int16_t cterm_fg_color, cterm_bg_color;
  int32_t hl_blend;
  int32_t url;
} HlAttrs;

#define HLATTRS_INIT (HlAttrs) { \
  .rgb_ae_attr = 0, \
  .cterm_ae_attr = 0, \
  .rgb_fg_color = -1, \
  .rgb_bg_color = -1, \
  .rgb_sp_color = -1, \
  .cterm_fg_color = 0, \
Repository: neovim/neovim
File: runtime/ftplugin/query.lua (Lua)

Code before:
-- Neovim filetype plugin file
-- Language:	Treesitter query

if vim.b.did_ftplugin == 1 then
  return
end

-- Do not set vim.b.did_ftplugin = 1 to allow loading of ftplugin/lisp.vim

-- use treesitter over syntax
vim.treesitter.start()

-- set omnifunc
vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'

vim.opt_local.iskeyword:append('.')

-- query linter
local buf = vim.api.nvim_get_current_buf()
local query_lint_on = vim.g.query_lint_on or { }

if not vim.b.disable_query_linter and #query_lint_on > 0 then
  vim.api.nvim_create_autocmd(query_lint_on, {
    group = vim.api.nvim_create_augroup('nvim.querylint', { clear = false }),
    buffer = buf,
    callback = function()
      vim.treesitter.query.lint(buf)
    end,
    desc = 'Query linter',
  })
end

-- it's a lisp!
vim.cmd([[runtime! ftplugin/lisp.vim]])

vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl omnifunc< iskeyword<'
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'


Review comment (suggestion):
```suggestion
local query_lint_on = vim.g.query_lint_on or {}
```

Code after:
-- Neovim filetype plugin file
-- Language:	Treesitter query

if vim.b.did_ftplugin == 1 then
  return
end

-- Do not set vim.b.did_ftplugin = 1 to allow loading of ftplugin/lisp.vim

-- use treesitter over syntax
vim.treesitter.start()

-- set omnifunc
vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'

vim.opt_local.iskeyword:append('.')

-- query linter
local buf = vim.api.nvim_get_current_buf()
local query_lint_on = vim.g.query_lint_on or {}

if not vim.b.disable_query_linter and #query_lint_on > 0 then
  vim.api.nvim_create_autocmd(query_lint_on, {
    group = vim.api.nvim_create_augroup('nvim.querylint', { clear = false }),
    buffer = buf,
    callback = function()
      vim.treesitter.query.lint(buf)
    end,
    desc = 'Query linter',
  })
end

-- it's a lisp!
vim.cmd([[runtime! ftplugin/lisp.vim]])

vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl omnifunc< iskeyword<'
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'
Repository: neovim/neovim
File: src/nvim/channel.c (C)

Code before:
  }

  Proc *proc = &chan->stream.proc;
  proc->argv = argv;
  proc->exepath = exepath;
  proc->cb = channel_proc_exit_cb;
  proc->state_cb = channel_proc_state_cb;
  proc->events = chan->events;
  proc->detach = detach;
  proc->cwd = cwd;
  proc->env = env;
  proc->overlapped = overlapped;

  char *cmd = xstrdup(proc_get_exepath(proc));
  bool has_out, has_err;
  if (proc->type == kProcTypePty) {
    has_out = true;
    has_err = false;
  } else {
    has_out = rpc || callback_reader_set(chan->on_data);
    has_err = callback_reader_set(chan->on_stderr);
    proc->fwd_err = chan->on_stderr.fwd_err;
  }

  bool has_in = stdin_mode == kChannelStdinPipe;

  int status = proc_spawn(proc, has_in, has_out, has_err);
  if (status) {
    semsg(_(e_jobspawn), os_strerror(status), cmd);
    xfree(cmd);
    if (proc->env) {
      tv_dict_free(proc->env);
    }
    channel_destroy_early(chan);
    *status_out = proc->status;
    return NULL;
  }
  xfree(cmd);
  if (proc->env) {
    tv_dict_free(proc->env);
  }

  if (has_in) {
    wstream_init(&proc->in, 0);
  }
  if (has_out) {
    rstream_init(&proc->out);
  }

  if (rpc) {
    // the rpc takes over the in and out streams

Review comment (suggestion):
These tricky channel details suggest that `vim.system` should be implemented on top of `jobstart` (or we need to expose channel internals some other way so that `vim.system` can re-use them), rather than using naked `vim.uv`. @lewis6991

Related:

- https://github.com/neovim/neovim/issues/26861
- https://github.com/neovim/neovim/issues/24571

Code after:
  }

  Proc *proc = &chan->stream.proc;
  proc->argv = argv;
  proc->exepath = exepath;
  proc->cb = channel_proc_exit_cb;
  proc->state_cb = channel_proc_state_cb;
  proc->events = chan->events;
  proc->detach = detach;
  proc->cwd = cwd;
  proc->env = env;
  proc->overlapped = overlapped;

  char *cmd = xstrdup(proc_get_exepath(proc));
  bool has_out, has_err;
  if (proc->type == kProcTypePty) {
    has_out = true;
    has_err = false;
  } else {
    has_out = rpc || callback_reader_set(chan->on_data);
    has_err = callback_reader_set(chan->on_stderr);
    proc->fwd_err = chan->on_stderr.fwd_err;
#ifdef MSWIN
    // DETACHED_PROCESS can't inherit console handles (like ConPTY stderr).
    // Use a pipe relay: libuv creates a pipe, on_channel_output writes to stderr.
    if (!has_err && proc->fwd_err && proc->detach) {
      has_err = true;
      proc->fwd_err = false;
    }
#endif
  }

  bool has_in = stdin_mode == kChannelStdinPipe;

  int status = proc_spawn(proc, has_in, has_out, has_err);
  if (status) {
    semsg(_(e_jobspawn), os_strerror(status), cmd);
    xfree(cmd);
    if (proc->env) {
      tv_dict_free(proc->env);
    }
    channel_destroy_early(chan);
    *status_out = proc->status;
    return NULL;
  }
  xfree(cmd);
  if (proc->env) {
    tv_dict_free(proc->env);
  }

  if (has_in) {
Repository: neovim/neovim
File: src/nvim/main.c (C)

Code before:
/// @return def unmodified if:
///   - argument isn't given
///   - argument is non-numeric
///
/// @return argument's numeric value otherwise
static int get_number_arg(const char *p, int *idx, int def)
  FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
  if (ascii_isdigit(p[*idx])) {
    def = atoi(&(p[*idx]));
    while (ascii_isdigit(p[*idx])) {
      *idx = *idx + 1;
    }
  }
  return def;
}

static uint64_t server_connect(char *server_addr, const char **errmsg)
{
  if (server_addr == NULL) {
    *errmsg = "no address specified";
    return 0;
  }
  CallbackReader on_data = CALLBACK_READER_INIT;
  const char *error = NULL;
  bool is_tcp = socket_address_tcp_host_end(server_addr) ? true : false;
  // connected to channel
  uint64_t chan = channel_connect(is_tcp, server_addr, true, on_data, 500, &error);
  if (error) {
    *errmsg = error;
    return 0;
  }
  return chan;
}

/// Handle remote subcommands
static void remote_request(mparm_T *params, int remote_args, char *server_addr, int argc,
                           char **argv, bool ui_only)
{
  bool is_ui = strequal(argv[remote_args], "--remote-ui");
  if (ui_only && !is_ui) {
    // TODO(bfredl): this implies always starting the TUI.
    // if we be smart we could delay this past should_exit
    return;
  }

  const char *connect_error = NULL;
  uint64_t chan = server_connect(server_addr, &connect_error);
  Object rvobj = OBJECT_INIT;

  if (is_ui) {

Review comment (suggestion):
```suggestion
  bool is_tcp = socket_address_tcp_host_end(server_addr) != NULL;
```

Code after:
/// @return def unmodified if:
///   - argument isn't given
///   - argument is non-numeric
///
/// @return argument's numeric value otherwise
static int get_number_arg(const char *p, int *idx, int def)
  FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
  if (ascii_isdigit(p[*idx])) {
    def = atoi(&(p[*idx]));
    while (ascii_isdigit(p[*idx])) {
      *idx = *idx + 1;
    }
  }
  return def;
}

static uint64_t server_connect(char *server_addr, const char **errmsg)
{
  if (server_addr == NULL) {
    *errmsg = "no address specified";
    return 0;
  }
  CallbackReader on_data = CALLBACK_READER_INIT;
  const char *error = NULL;
  bool is_tcp = socket_address_tcp_host_end(server_addr) != NULL;
  // connected to channel
  uint64_t chan = channel_connect(is_tcp, server_addr, true, on_data, 500, &error);
  if (error) {
    *errmsg = error;
    return 0;
  }
  return chan;
}

/// Handle remote subcommands
static void remote_request(mparm_T *params, int remote_args, char *server_addr, int argc,
                           char **argv, bool ui_only)
{
  bool is_ui = strequal(argv[remote_args], "--remote-ui");
  if (ui_only && !is_ui) {
    // TODO(bfredl): this implies always starting the TUI.
    // if we be smart we could delay this past should_exit
    return;
  }

  const char *connect_error = NULL;
  uint64_t chan = server_connect(server_addr, &connect_error);
  Object rvobj = OBJECT_INIT;

  if (is_ui) {
Repository: neovim/neovim
File: runtime/pack/dist/opt/nvim.difftool/plugin/difftool.lua (Lua)

Code before:
if vim.g.loaded_difftool ~= nil then
  return
end
vim.g.loaded_difftool = true

vim.api.nvim_create_user_command('DiffTool', function(opts)
  if #opts.fargs == 2 then
    require('difftool').open(opts.fargs[1], opts.fargs[2])
  else
    vim.notify('Usage: DiffTool <left> <right>', vim.log.levels.ERROR)
  end
end, { nargs = '*', complete = 'file' })

local function start_diff()
  if not vim.o.diff then
    return
  end
  local args = vim.v.argf
  if #args == 2 then
    vim.schedule(function()
      require('difftool').open(args[1], args[2])
    end)
  end
end

if vim.v.vim_did_enter > 0 then
  start_diff()
  return
end
vim.api.nvim_create_autocmd('VimEnter', {
  callback = start_diff,
})


Review comment (suggestion):
can we give a hint about the purpose

```suggestion
-- Provide "diff mode", e.g. via "nvim -d ...".
-- Currently, user opts-in to this via :packadd.
local function start_diff()
```

Code after:
if vim.g.loaded_difftool ~= nil then
  return
end
vim.g.loaded_difftool = true

vim.api.nvim_create_user_command('DiffTool', function(opts)
  if #opts.fargs == 2 then
    require('difftool').open(opts.fargs[1], opts.fargs[2])
  else
    vim.notify('Usage: DiffTool <left> <right>', vim.log.levels.ERROR)
  end
end, { nargs = '*', complete = 'file' })

-- If we are in diff mode (e.g. `nvim -d file1 file2`), open the difftool automatically.
local function start_diff()
  if not vim.o.diff then
    return
  end
  local args = vim.v.argf
  if #args == 2 then
    vim.schedule(function()
      require('difftool').open(args[1], args[2])
    end)
  end
end
if vim.v.vim_did_enter > 0 then
  start_diff()
  return
end
vim.api.nvim_create_autocmd('VimEnter', {
  callback = start_diff,
})
Repository: neovim/neovim
File: runtime/lua/vim/fs.lua (Lua)

Code before:
end

--- Concatenates partial paths (one absolute or relative path followed by zero or more relative
--- paths). Slashes are normalized: redundant slashes are removed, and (on Windows) backslashes are
--- replaced with forward-slashes. Empty segments are removed. Paths are not expanded/resolved.
---
--- Examples:
--- - "foo/", "/bar" => "foo/bar"
--- - "", "after/plugin" => "after/plugin"
--- - Windows: "a\foo\", "\bar" => "a/foo/bar"
---
---@since 12
---@param ... string
---@return string
function M.joinpath(...)
  local n = select('#', ...)
  ---@type string[]
  local segments = {}
  for i = 1, n do
    local s = select(i, ...)
    if s and #s > 0 then
      segments[#segments+1] = s
    end
  end

  local path = table.concat(segments, '/')

  return (path:gsub(iswin and '[/\\][/\\]*' or '//+', '/'))
end

--- @class vim.fs.dir.Opts
--- @inlinedoc
---
--- How deep to traverse.
--- (default: `1`)
--- @field depth? integer
---
--- Predicate to control traversal.
--- Return false to stop searching the current directory.
--- Only useful when depth > 1
--- Return an iterator over the items located in {path}
--- @field skip? (fun(dir_name: string): boolean)
---
--- Follow symbolic links.
--- (default: `false`)
--- @field follow? boolean

---@alias Iterator fun(): string?, string?

--- Gets an iterator over items found in `path` (normalized via |vim.fs.normalize()|).
---

Review comment (suggestion):
if we are only collecting stuff into `segments` to join into a string, maybe using a stringbuffer is more performant: https://github.com/neovim/neovim/blob/583308f5991c4c55d3f04e456254d95433033c72/runtime/lua/vim/lsp/rpc.lua#L4

Code after:
end

--- Concatenates partial paths (one absolute or relative path followed by zero or more relative
--- paths). Slashes are normalized: redundant slashes are removed, and (on Windows) backslashes are
--- replaced with forward-slashes. Empty segments are removed. Paths are not expanded/resolved.
---
--- Examples:
--- - "foo/", "/bar" => "foo/bar"
--- - "", "after/plugin" => "after/plugin"
--- - Windows: "a\foo\", "\bar" => "a/foo/bar"
---
---@since 12
---@param ... string
---@return string
function M.joinpath(...)
  local n = select('#', ...)
  ---@type string[]
  local segments = {}
  for i = 1, n do
    local s = select(i, ...)
    if s and #s > 0 then
      segments[#segments + 1] = s
    end
  end

  local path = table.concat(segments, '/')

  return (path:gsub(iswin and '[/\\][/\\]*' or '//+', '/'))
end

--- @class vim.fs.dir.Opts
--- @inlinedoc
---
--- How deep to traverse.
--- (default: `1`)
--- @field depth? integer
---
--- Predicate to control traversal.
--- Return false to stop searching the current directory.
--- Only useful when depth > 1
--- Return an iterator over the items located in {path}
--- @field skip? (fun(dir_name: string): boolean)
---
--- Follow symbolic links.
--- (default: `false`)
--- @field follow? boolean

---@alias Iterator fun(): string?, string?

--- Gets an iterator over items found in `path` (normalized via |vim.fs.normalize()|).
---
Repository: netty/netty
File: codec/src/test/java/io/netty/handler/codec/compression/ZstdDecoderTest.java (Java)

Code before:
 * 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 io.netty.handler.codec.compression;

import com.github.luben.zstd.ZstdOutputStream;
import io.netty.channel.embedded.EmbeddedChannel;

import java.io.ByteArrayOutputStream;

public class ZstdDecoderTest extends AbstractDecoderTest {

    public ZstdDecoderTest() throws Exception {
    }

    @Override
    public EmbeddedChannel createChannel() {
        return new EmbeddedChannel(new ZstdDecoder());
    }

    @Override
    protected byte[] compress(byte[] data) throws Exception {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        ZstdOutputStream zstdOs = new ZstdOutputStream(os);
        zstdOs.write(data);
        zstdOs.close();

        return os.toByteArray();
    }
}


Review comment (suggestion):
Let's use `ZstdOutputStreamNoFinalizer` instead, to avoid allocating a `Finalizer` object every time.

Code after:
 * 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 io.netty.handler.codec.compression;

import com.github.luben.zstd.Zstd;
import io.netty.channel.embedded.EmbeddedChannel;


public class ZstdDecoderTest extends AbstractDecoderTest {

    public ZstdDecoderTest() throws Exception {
    }

    @Override
    public EmbeddedChannel createChannel() {
        return new EmbeddedChannel(new ZstdDecoder());
    }

    @Override
    protected byte[] compress(byte[] data) throws Exception {
        return Zstd.compress(data);
    }
}
Repository: netty/netty
File: resolver-dns/src/main/java/io/netty/resolver/dns/ThreadLocalNameServerAddressStream.java (Java)

Code before:
/*
 * Copyright 2015 The Netty Project
 *
 * The Netty Project 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:
 *
 *   https://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 io.netty.resolver.dns;

import io.netty.util.concurrent.FastThreadLocal;

import java.net.InetSocketAddress;

/**
 * A thread local based address stream for a specific hostname.
 */
class ThreadLocalNameServerAddressStream implements DnsServerAddressStream {

    private final String hostname;

Review comment (suggestion):
```suggestion
 * Copyright 2024 The Netty Project
```

Code after:
/*
 * Copyright 2024 The Netty Project
 *
 * The Netty Project 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:
 *
 *   https://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 io.netty.resolver.dns;

import io.netty.util.concurrent.FastThreadLocal;

import java.net.InetSocketAddress;

/**
 * A thread local based address stream for a specific hostname.
 */
final class ThreadLocalNameServerAddressStream implements DnsServerAddressStream {

    private final String hostname;
Repository: netty/netty
File: resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverBuilderTest.java (Java)

Code before:
            //no-op
        }

        @Override
        public void clear() {
            //no-op
        }

        @Override
        public boolean clear(String hostname) {
            return false;
        }
    }

    @Test
    void testCustomQueryDnsServerAddressStream() {
        DnsServerAddressStream queryAddressStream = new TestQueryServerAddressStream();
        resolver = builder.queryServerAddressStream(queryAddressStream).build();

        assertThat(resolver.queryDnsServerAddressStream()).isSameAs(queryAddressStream);

        resolver = builder.copy().build();
        assertThat(resolver.queryDnsServerAddressStream()).isSameAs(queryAddressStream);
    }

    private static class TestQueryServerAddressStream implements DnsServerAddressStream {

        @Override
        public InetSocketAddress next() {
            throw new UnsupportedOperationException();
        }

        @Override
        public int size() {
            throw new UnsupportedOperationException();
        }

        @Override
        public DnsServerAddressStream duplicate() {
            throw new UnsupportedOperationException();
        }
    }
}


Review comment (suggestion):
```suggestion
    private static final class TestQueryServerAddressStream implements DnsServerAddressStream {
```

Code after:
        }

        @Override
        public void clear() {
            //no-op
        }

        @Override
        public boolean clear(String hostname) {
            return false;
        }
    }

    @Test
    void testCustomQueryDnsServerAddressStream() {
        DnsServerAddressStream queryAddressStream = new TestQueryServerAddressStream();
        resolver = builder.queryServerAddressStream(queryAddressStream).build();

        assertThat(resolver.queryDnsServerAddressStream()).isSameAs(queryAddressStream);

        resolver = builder.copy().build();
        assertThat(resolver.queryDnsServerAddressStream()).isSameAs(queryAddressStream);
    }

    private static final class TestQueryServerAddressStream implements DnsServerAddressStream {

        @Override
        public InetSocketAddress next() {
            throw new UnsupportedOperationException();
        }

        @Override
        public int size() {
            throw new UnsupportedOperationException();
        }

        @Override
        public DnsServerAddressStream duplicate() {
            throw new UnsupportedOperationException();
        }
    }
}