Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
5701a74a
Unverified
Commit
5701a74a
authored
5 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Simplify Quartz classloader helper; task namespaces already required
parent
046254ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/task.clj
+1
-26
1 addition, 26 deletions
src/metabase/task.clj
with
1 addition
and
26 deletions
src/metabase/task.clj
+
1
−
26
View file @
5701a74a
...
...
@@ -102,33 +102,8 @@
;;; | Quartz Scheduler Class Load Helper |
;;; +----------------------------------------------------------------------------------------------------------------+
;; Custom `ClassLoadHelper` implementation that makes sure to require the namespaces that tasks live in (to make sure
;; record types are loaded) and that uses our canonical ClassLoader.
(
defn-
task-class-name->namespace-str
"Determine the namespace we need to load for one of our tasks.
(task-class-name->namespace-str \"metabase.task.upgrade_checks.CheckForNewVersions\")
;; -> \"metabase.task.upgrade-checks\""
[
class-name
]
(
->
class-name
(
str/replace
\_
\-
)
(
str/replace
#
"\.\w+$"
""
)))
(
defn-
require-task-namespace
"Since Metabase tasks are defined in Clojure-land we need to make sure we `require` the namespaces where they are
defined before we try to load the task classes."
[
class-name
]
;; call `the-classloader` to force side-effects of making it the current thread context classloader
(
classloader/the-classloader
)
;; only try to `require` metabase.task classes; don't do this for other stuff that gets shuffled thru here like
;; Quartz classes
(
when
(
str/starts-with?
class-name
"metabase.task."
)
(
require
(
symbol
(
task-class-name->namespace-str
class-name
)))))
(
defn-
load-class
^
Class
[
^
String
class-name
]
(
require-task-namespace
class-name
)
(
.loadClass
(
classloader/the-classloader
)
class-name
))
(
Class/forName
class-name
true
(
classloader/the-classloader
)))
(
defrecord
^
:private
ClassLoadHelper
[]
org.quartz.spi.ClassLoadHelper
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment