Skip to content

Roundtrip fails when max_nesting or max_bytesize is exceeded. #3

@bradland

Description

@bradland

When limits defined by max_nesting or max_bytesize options are encountered, roundtrip operations fail. The problem is illustrated in the following script:

require 'lines'
require 'json'
require 'yaml'

class LinesRoundtrip
  ::DATA = {
    large: { "foo" => "b#{'a'*2048}r" },
    small: { "foo" => "bar" }
  }

  def run!
    roundtrip DATA[:small], Lines
    roundtrip DATA[:small], JSON
    roundtrip DATA[:small], YAML
    roundtrip DATA[:large], Lines
    roundtrip DATA[:large], JSON
    roundtrip DATA[:large], YAML
  end

  def roundtrip(data, serializer)
    puts "Attempting to roundtrip using #{serializer.name}:"
    puts "  #{data.inspect}"
    dump = serializer.dump(data)
    load = serializer.load(dump)

    puts "Ended up with:"
    puts "  #{load.inspect}"
    puts "---"
  end
end

begin
  if $0 == __FILE__
    LinesRoundtrip.new().run!
  end
rescue Interrupt
  # Ctrl^C
  exit 130
rescue Errno::EPIPE
  # STDOUT was closed
  exit 74 # EX_IOERR
end

When that script is run, Lines fails to roundtrip the large value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions