Skip to content

Commit cdc1911

Browse files
committed
Fix flaky Ephemeris specs
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
1 parent a024918 commit cdc1911

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lib/openhab/rspec/karaf.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def start_instance
143143

144144
set_up_bundle_listener
145145
wait_for_start
146+
set_context_class_loader_for_jollyday
146147
Mocks::SynchronousExecutor.instance.main_thread = Thread.current
147148
set_jruby_script_presets
148149
@main
@@ -475,12 +476,22 @@ def set_up_bundle_listener
475476
puts e.backtrace
476477
end
477478
@bundle_context.bundles.each do |bundle|
478-
next unless bundle.symbolic_name.start_with?("org.openhab.core")
479+
next unless bundle.symbolic_name.start_with?("org.openhab.core", "de.focus_shift.jollyday")
479480

480481
add_class_loader(bundle)
481482
end
482483
end
483484

485+
def set_context_class_loader_for_jollyday
486+
bundle = @bundle_context.bundles.find { |b| b.symbolic_name == "de.focus_shift.jollyday-jackson" }
487+
return unless bundle
488+
489+
loader = bundle.adapt(org.osgi.framework.wiring.BundleWiring.java_class)&.class_loader
490+
return unless loader
491+
492+
java.lang.Thread.currentThread.setContextClassLoader(loader)
493+
end
494+
484495
def set_up_service_listener
485496
@awaiting_services = {}
486497
@bundle_context.add_service_listener do |event|

0 commit comments

Comments
 (0)