Permalink
Browse files

RUBY-1024 Swallow RangeError when attempting to instantiate far-futur…

…e times on 32-bit Rubies
  • Loading branch information...
1 parent 6cee6b5 commit 807a8bd5a555e037e709a0885824e7f6a3575267 @benweint benweint committed Feb 19, 2013
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/new_relic/agent/instrumentation/queue_time.rb
@@ -52,8 +52,15 @@ def timestamp_string_from_header_value(value)
def parse_timestamp(string)
cut_off = Time.at(EARLIEST_ACCEPTABLE_TIMESTAMP)
[1_000_000, 1_000, 1].map do |divisor|
- Time.at(string.to_f / divisor)
- end.find {|candidate| candidate > cut_off }
+ begin
+ Time.at(string.to_f / divisor)
+ rescue RangeError
+ # On Ruby versions built with a 32-bit time_t, attempting to
+ # instantiate a Time object in the far future raises a RangeError,
+ # in which case we know we've chosen the wrong divisor.
+ nil
+ end
+ end.compact.find { |candidate| candidate > cut_off }
end
end
end

0 comments on commit 807a8bd

Please sign in to comment.