Skip to content

Commit 493448f

Browse files
author
Glyn Normington
committed
Cope with $MEMORY_LIMIT not being set
The warning code failed if $MEMORY_LIMIT is not set. Add a guard to allow it to cope. [#52692569]
1 parent e76b65f commit 493448f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

lib/java_buildpack/jre/memory/weight_balancing_memory_heuristic.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@ def issue_close_to_default_warnings(buckets, heuristics, memory_limit)
130130
buckets.each do |type, bucket|
131131
if @sizes[type]
132132
default_size = bucket.default_size
133-
actual_size = bucket.size
134-
if default_size != MemorySize.ZERO
135-
factor = ((actual_size - default_size) / default_size).abs
136-
end
137-
if (default_size == MemorySize.ZERO && actual_size == MemorySize.ZERO) || factor < CLOSE_TO_DEFAULT_FACTOR
138-
$stderr.puts "-----> WARNING: the configured value #{actual_size} of memory size #{type} is close to the default value #{default_size}. Consider deleting the configured value and taking the default."
133+
if default_size
134+
actual_size = bucket.size
135+
if default_size != MemorySize.ZERO
136+
factor = ((actual_size - default_size) / default_size).abs
137+
end
138+
if (default_size == MemorySize.ZERO && actual_size == MemorySize.ZERO) || factor < CLOSE_TO_DEFAULT_FACTOR
139+
$stderr.puts "-----> WARNING: the configured value #{actual_size} of memory size #{type} is close to the default value #{default_size}. Consider deleting the configured value and taking the default."
140+
end
139141
end
140142
end
141143
end

0 commit comments

Comments
 (0)