diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /lib/gitlab/utils/log_limited_array.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'lib/gitlab/utils/log_limited_array.rb')
-rw-r--r-- | lib/gitlab/utils/log_limited_array.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/gitlab/utils/log_limited_array.rb b/lib/gitlab/utils/log_limited_array.rb index e0589c3df4c..fbbba568d14 100644 --- a/lib/gitlab/utils/log_limited_array.rb +++ b/lib/gitlab/utils/log_limited_array.rb @@ -9,14 +9,14 @@ module Gitlab # to around 10 kilobytes. Once we hit the limit, add the sentinel # value as the last item in the returned array. def self.log_limited_array(array, sentinel: '...') - return [] unless array.is_a?(Array) + return [] unless array.is_a?(Array) || array.is_a?(Enumerator::Lazy) total_length = 0 limited_array = array.take_while do |arg| total_length += JsonSizeEstimator.estimate(arg) total_length <= MAXIMUM_ARRAY_LENGTH - end + end.to_a limited_array.push(sentinel) if total_length > MAXIMUM_ARRAY_LENGTH |