Skip to content

Commit

Permalink
Internal: Remove ClassLoader from Settings
Browse files Browse the repository at this point in the history
Settings currently has a classloader member, which any user (plugin
or core ES code) can access to load classes/resources. This is extremely
error prone as setting the classloder on the Settings instance is a
public method. Furthermore, it is not really necessary. Classes that
need resources should load resources using normal means
(getClass().getResourceAsStream). Those that need classes
should use Class.forName, which will load the class with the
same classloader as the calling class. This means, in the few
places where classes are loaded by string name, they will use
the appropriate loader: either the default classloader which loads
core ES code, or a child classloader for each plugin.

This change removes the classloader member from Settings, as
well as other classloader related uses (except for a handful
of cases which must use a classloader, at least for now).

Backport of #12868
  • Loading branch information
rjernst committed Aug 19, 2015
1 parent 3cff501 commit 7a67924
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -226,7 +226,7 @@ public void testQueryModeCommonGramsAnalysis() throws IOException {
String json = "/org/elasticsearch/index/analysis/commongrams/commongrams_query_mode.json";
Settings settings = Settings.settingsBuilder()
.loadFromStream(json, getClass().getResourceAsStream(json))
.put("path.home", createHome())
.put("path.home", createHome())
.build();
{
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settings);
Expand Down

0 comments on commit 7a67924

Please sign in to comment.