intridea/multi_json

Passing adapter in options throws NPE

chetan opened this issue · 3 comments

If you pass an adapter in the load/dump call and that adapter hasn't been used before, then an error is thrown since the adapter is never properly activated via adapter.activate!. See the following gist:

https://gist.github.com/chetan/5724882

The fix seems somewhat straightforward but I'm not sure if this would be best here:

  def current_adapter(options={})
    if new_adapter = options[:adapter]
      a = load_adapter(new_adapter)
      a.activate!
      a
    else
      adapter
    end
  end

BTW, I just noticed that the Adapter.activate! method was removed in the fix. Looks good, but it does break API.. may want to throw a no-op in there to avoid affecting people downstream.

rwz commented

@chetan it was never part of public API in the first place, I'd rather not keep it unless it really breaks some production code. Does this concerns you anyhow?

How do you define "public API" ? It did break code for me cause I had called it as a workaround for this bug.