Skip to content

Commit dd5f69a

Browse files
committed
Look to buildpack local cache
This is the sixth step in creating an offline buildpack. This change causes the ApplicationCache to look at a local location (resources/cache) for resources when it cannot download them. This simple requirement led to extensive changes to the DownloadCache implementation. The changes mostly had to do with removing code that causes filesystem locking for cached resources. Since the cache can no longer be shared between processes (there is no global cache) there was no need for the added complexity of the filesystem locking. In addition, the behavior around detecting when the network was unavailable was overly complex. This change eliminates all excess calls to determine connectivity, instead using the needed calls to determine it. [#67852466]
1 parent 989e6a4 commit dd5f69a

32 files changed

Lines changed: 597 additions & 1479 deletions

.idea/dictionaries/bhale.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.rubocop.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ AllCops:
77
- build/**
88
ClassLength:
99
Max: 200
10-
ClassVars:
11-
Enabled: false
1210
CyclomaticComplexity:
1311
Max: 10
1412
Documentation:

lib/java_buildpack/buildpack.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def release
100100
LOAD_ROOT = Pathname.new(__FILE__).dirname + '..'
101101

102102
def initialize(app_dir, application)
103-
@logger = Logging::LoggerFactory.get_logger Buildpack
103+
@logger = Logging::LoggerFactory.instance.get_logger Buildpack
104104

105105
log_environment_variables
106106

@@ -201,7 +201,7 @@ class << self
201201
def with_buildpack(app_dir, message)
202202
app_dir = Pathname.new(File.expand_path(app_dir))
203203
application = Component::Application.new(app_dir)
204-
Logging::LoggerFactory.setup app_dir
204+
Logging::LoggerFactory.instance.setup app_dir
205205

206206
yield new(app_dir, application) if block_given?
207207
rescue => e
@@ -211,7 +211,7 @@ def with_buildpack(app_dir, message)
211211
private
212212

213213
def handle_error(e, message)
214-
logger = Logging::LoggerFactory.get_logger Buildpack
214+
logger = Logging::LoggerFactory.instance.get_logger Buildpack
215215

216216
logger.error { message % e.inspect }
217217
logger.debug { "Exception #{e.inspect} backtrace:\n#{e.backtrace.join("\n")}" }

lib/java_buildpack/component/droplet.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def initialize(additional_libraries, component_id, java_home, java_opts, root)
7373
@component_id = component_id
7474
@java_home = java_home
7575
@java_opts = java_opts
76-
@logger = JavaBuildpack::Logging::LoggerFactory.get_logger Droplet
76+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger Droplet
7777

7878
buildpack_root = root + '.java-buildpack'
7979
sandbox_root = buildpack_root + component_id
@@ -102,7 +102,7 @@ def copy_resources(target_directory = @sandbox)
102102

103103
private
104104

105-
RESOURCES_DIRECTORY = Pathname.new(File.expand_path('../../../../resources', __FILE__))
105+
RESOURCES_DIRECTORY = Pathname.new(File.expand_path('../../../../resources', __FILE__)).freeze
106106

107107
def in?(path, root)
108108
path.ascend do |parent|

lib/java_buildpack/component/services.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def one_service?(filter, *required_credentials)
4545
if credentials?(candidates.first['credentials'], required_credentials)
4646
match = true
4747
else
48-
logger = JavaBuildpack::Logging::LoggerFactory.get_logger Services
48+
logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger Services
4949
logger.warn do
5050
"A service with a name label or tag matching #{filter} was found, but was missing one of the required" \
5151
" credentials #{required_credentials}"

lib/java_buildpack/container/groovy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Groovy < JavaBuildpack::Component::VersionedDependencyComponent
3838
#
3939
# @param [Hash] context a collection of utilities used the component
4040
def initialize(context)
41-
@logger = JavaBuildpack::Logging::LoggerFactory.get_logger Groovy
41+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger Groovy
4242
super(context) { |candidate_version| candidate_version.check_size(3) }
4343
end
4444

lib/java_buildpack/container/spring_boot_cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SpringBootCLI < JavaBuildpack::Component::VersionedDependencyComponent
3434
#
3535
# @param [Hash] context a collection of utilities used the component
3636
def initialize(context)
37-
@logger = JavaBuildpack::Logging::LoggerFactory.get_logger SpringBootCLI
37+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger SpringBootCLI
3838
super(context)
3939
end
4040

lib/java_buildpack/framework/spring_auto_reconfiguration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SpringAutoReconfiguration < JavaBuildpack::Component::VersionedDependencyC
3131
# @param [Hash] context a collection of utilities used the component
3232
def initialize(context)
3333
super(context)
34-
@logger = JavaBuildpack::Logging::LoggerFactory.get_logger SpringAutoReconfiguration
34+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger SpringAutoReconfiguration
3535
end
3636

3737
# (see JavaBuildpack::Component::BaseComponent#compile)

lib/java_buildpack/jre/memory/memory_bucket.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def initialize(name, weighting, range)
4848
@name = validate_name name
4949
@weighting = validate_weighting weighting
5050
@range = range ? validate_memory_range(range) : nil
51-
logger = JavaBuildpack::Logging::LoggerFactory.get_logger MemoryBucket
51+
logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger MemoryBucket
5252
logger.debug { inspect }
5353
end
5454

lib/java_buildpack/jre/memory/weight_balancing_memory_heuristic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class WeightBalancingMemoryHeuristic
3636
# @param [Array<String>] valid_types the valid types of memory
3737
# @param [Hash<String, String>] java_opts a mapping from a memory type to a +JAVA_OPTS+ option
3838
def initialize(sizes, heuristics, valid_types, java_opts)
39-
@logger = JavaBuildpack::Logging::LoggerFactory.get_logger WeightBalancingMemoryHeuristic
39+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger WeightBalancingMemoryHeuristic
4040
validate 'size', valid_types, sizes.keys
4141
validate 'heuristic', valid_types, heuristics.keys
4242
@memory_limit = MemoryLimit.memory_limit

0 commit comments

Comments
 (0)