lib/elasticsearch/transport/transport/base.rb in elasticsearch-transport-1.0.17 vs lib/elasticsearch/transport/transport/base.rb in elasticsearch-transport-1.0.18
- old
+ new
@@ -106,11 +106,11 @@
@options = arguments[:options] || {}
__close_connections
new_connections = __build_connections
- stale_connections = @connections.select { |c| ! new_connections.include?(c) }
+ stale_connections = @connections.all.select { |c| ! new_connections.include?(c) }
new_connections = new_connections.reject { |c| @connections.include?(c) }
@connections.remove(stale_connections)
@connections.add(new_connections)
@connections
@@ -310,10 +310,10 @@
__trace method, path, params, body, url, response, nil, 'N/A', duration if tracer
__log_failed response if logger
__raise_transport_error response
end
- json = serializer.load(response.body) if response.headers && response.headers["content-type"] =~ /json/
+ json = serializer.load(response.body) if response.body && !response.body.empty? && response.headers && response.headers["content-type"] =~ /json/
took = (json['took'] ? sprintf('%.3fs', json['took']/1000.0) : 'n/a') rescue 'n/a' if logger || tracer
__log method, path, params, body, url, response, json, took, duration if logger
__trace method, path, params, body, url, response, json, took, duration if tracer