Skip to content

Commit 70d4e13

Browse files
author
Glyn Normington
committed
Merge 59817096-ENETUNREACH to master
[Completes #59817096]
2 parents e65629e + 3d76f80 commit 70d4e13

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/java_buildpack/util/download_cache.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,17 @@ def evict(uri)
105105

106106
HTTP_ERRORS = [
107107
EOFError,
108+
Errno::ECONNABORTED,
108109
Errno::ECONNREFUSED,
109110
Errno::ECONNRESET,
111+
Errno::EHOSTDOWN,
110112
Errno::EHOSTUNREACH,
111113
Errno::EINVAL,
114+
Errno::ENETDOWN,
115+
Errno::ENETRESET,
116+
Errno::ENETUNREACH,
117+
Errno::ENONET,
118+
Errno::ENOTCONN,
112119
Errno::EPIPE,
113120
Errno::ETIMEDOUT,
114121
Net::HTTPBadResponse,

spec/java_buildpack/util/download_cache_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,23 @@ def suppress_internet_availability_check
355355
end
356356
end
357357

358+
it 'should use the buildpack cache if the download cannot be completed because Errno::ENETUNREACH is raised' do
359+
stub_request(:get, 'http://foo-uri/').to_raise(Errno::ENETUNREACH)
360+
361+
Dir.mktmpdir do |root|
362+
Dir.mktmpdir do |buildpack_cache|
363+
java_buildpack_cache = File.join(buildpack_cache, 'java-buildpack')
364+
FileUtils.mkdir_p java_buildpack_cache
365+
touch java_buildpack_cache, 'cached', 'foo-stashed'
366+
with_buildpack_cache(buildpack_cache) do
367+
DownloadCache.new(root).get('http://foo-uri/') do |file|
368+
expect(file.read).to eq('foo-stashed')
369+
end
370+
end
371+
end
372+
end
373+
end
374+
358375
it 'should use the buildpack cache if the cache configuration disables remote downloads' do
359376
YAML.stub(:load_file).with(File.expand_path('config/cache.yml')).and_return(
360377
'remote_downloads' => 'disabled')

0 commit comments

Comments
 (0)