DBZ-5561 Use TCCL to load configuration classes by default

This commit is contained in:
Alexey Loubyansky 2022-08-29 14:58:32 +02:00 committed by Jiri Pechanec
parent 9f811a6f64
commit c4b95f4ea2
2 changed files with 6 additions and 5 deletions

View File

@ -15,6 +15,7 @@ Alex Soto
Alexander Iskuskov
Alexander Kovryga
Alexander Schwartz
Alexey Loubyansky
Alexey Miroshnikov
Alfusainey Jallow
Alisa Houskova

View File

@ -1440,7 +1440,7 @@ default Duration getDuration(Field field, TemporalUnit unit) {
* configuration but the value could not be converted to an existing class with a zero-argument constructor
*/
default <T> T getInstance(String key, Class<T> type) {
return getInstance(key, type, () -> getClass().getClassLoader());
return getInstance(key, type, () -> Thread.currentThread().getContextClassLoader());
}
/**
@ -1468,7 +1468,7 @@ default <T> T getInstance(String key, Class<T> type, Supplier<ClassLoader> class
* configuration but the value could not be converted to an existing class with a zero-argument constructor
*/
default <T> T getInstance(String key, Class<T> clazz, Configuration configuration) {
return Instantiator.getInstance(getString(key), () -> getClass().getClassLoader(), configuration);
return Instantiator.getInstance(getString(key), () -> Thread.currentThread().getContextClassLoader(), configuration);
}
/**
@ -1480,7 +1480,7 @@ default <T> T getInstance(String key, Class<T> clazz, Configuration configuratio
* configuration but the value could not be converted to an existing class with a zero-argument constructor
*/
default <T> T getInstance(Field field, Class<T> clazz) {
return getInstance(field, clazz, () -> getClass().getClassLoader());
return getInstance(field, clazz, () -> Thread.currentThread().getContextClassLoader());
}
/**
@ -1508,7 +1508,7 @@ default <T> T getInstance(Field field, Class<T> type, Supplier<ClassLoader> clas
* configuration but the value could not be converted to an existing class with a zero-argument constructor
*/
default <T> T getInstance(Field field, Class<T> clazz, Configuration configuration) {
return Instantiator.getInstance(getString(field), () -> getClass().getClassLoader(), configuration);
return Instantiator.getInstance(getString(field), () -> Thread.currentThread().getContextClassLoader(), configuration);
}
/**
@ -1522,7 +1522,7 @@ default <T> T getInstance(Field field, Class<T> clazz, Configuration configurati
* configuration but the value could not be converted to an existing class with a zero-argument constructor
*/
default <T> T getInstance(Field field, Class<T> clazz, Properties props) {
return Instantiator.getInstanceWithProperties(getString(field), () -> getClass().getClassLoader(), props);
return Instantiator.getInstanceWithProperties(getString(field), () -> Thread.currentThread().getContextClassLoader(), props);
}
/**