diff --git a/config.ru b/config.ru index fc414df..6084517 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,5 @@ require 'oj' +Oj.default_options = { :mode => :strict } opts = Oj.load( File.read('config.json') ) # prepare the logger diff --git a/optica.rb b/optica.rb index 8185ddc..c599c1b 100644 --- a/optica.rb +++ b/optica.rb @@ -91,7 +91,7 @@ def get_nodes(request, fields_to_include=nil) post '/' do begin - data = Oj.load request.body.read + data = Oj.load(request.body.read, :mode => :strict) rescue JSON::ParserError data = {} end diff --git a/store.rb b/store.rb index 354ff44..395b93f 100644 --- a/store.rb +++ b/store.rb @@ -174,7 +174,7 @@ def load_instances_from_leader uri = "http://localhost:%d/store" % @opts['split_mode_store_port'] res = open(uri, :read_timeout => @opts['split_mode_http_timeout']) - remote_store = Oj.load res.read + remote_store = Oj.load(res.read, :mode => :strict) [ remote_store['inst'], remote_store['idx'] ] rescue OpenURI::HTTPError, Errno::ECONNREFUSED, Net::ReadTimeout => e @log.error "Error loading store from #{uri}: #{e.inspect}; will retry after #{@opts['split_mode_retry_delay']}" @@ -322,7 +322,7 @@ def get_node(node) @zk.get(node) end STATSD.time('optica.json.parse') do - Oj.load(data) + Oj.load(data, :mode => :strict) end rescue ZK::Exceptions::NoNode @log.info "node #{node} disappeared"