Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
delight
delight
Commits
080dd238
Commit
080dd238
authored
Apr 11, 2019
by
Andreas Lauer
Browse files
fix: expect contextClassLoader to be null
Thread.currentThread().getContextClassLoader() may be null
parent
92cd1625
Changes
3
Hide whitespace changes
Inline
Side-by-side
delight-core/src/main/java/de/dfki/delight/Delight.java
View file @
080dd238
...
...
@@ -27,6 +27,8 @@ import de.dfki.delight.common.ParameterConversionManager;
import
de.dfki.delight.di.GuiceUtils
;
import
de.dfki.delight.transport.MethodCallSender
;
import
static
de
.
dfki
.
delight
.
server
.
util
.
ClassLoaderUtil
.
getContextClassLoader
;
/**
* Client part of delight. - allows to connect to some host and to use specific
* apis
...
...
@@ -180,8 +182,7 @@ public class Delight {
public
<
API
>
API
usingApi
(
final
String
handlerName
,
final
Class
<
API
>
apiClass
,
final
Class
<?>[]
parameterTypes
,
final
Object
[]
baseCtorArgs
)
{
return
usingApi
(
handlerName
,
apiClass
,
parameterTypes
,
baseCtorArgs
,
Thread
.
currentThread
().
getContextClassLoader
());
return
usingApi
(
handlerName
,
apiClass
,
parameterTypes
,
baseCtorArgs
,
getContextClassLoader
());
}
public
<
API
>
API
usingApi
(
final
String
handlerName
,
final
Class
<
API
>
apiClass
,
final
Class
<?>[]
parameterTypes
,
...
...
delight-core/src/main/java/de/dfki/delight/DelightConfigFinder.java
View file @
080dd238
package
de.dfki.delight
;
import
static
de
.
dfki
.
delight
.
server
.
util
.
ClassLoaderUtil
.
getContextClassLoader
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.Enumeration
;
...
...
@@ -30,7 +32,7 @@ public class DelightConfigFinder {
DelightConfigBuilder
defaultConfig
=
null
;
Class
<?
extends
ConfigProvider
>
defaultConfigProviderClass
=
null
;
String
defaultLocation
=
null
;
ClassLoader
classLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
ClassLoader
classLoader
=
getContextClassLoader
();
try
{
Enumeration
<
URL
>
resources
=
classLoader
.
getResources
(
DEFAULT_CONFIG_RESOURCE
);
if
(!
resources
.
hasMoreElements
())
{
...
...
delight-core/src/main/java/de/dfki/delight/server/util/ClassLoaderUtil.java
0 → 100644
View file @
080dd238
package
de.dfki.delight.server.util
;
public
class
ClassLoaderUtil
{
/**
* Get the current thread's context ClassLoader. If it is null, the ClassLoader of this class is used.
*/
public
static
ClassLoader
getContextClassLoader
()
{
ClassLoader
cl
=
Thread
.
currentThread
().
getContextClassLoader
();
if
(
cl
==
null
)
{
cl
=
ClassLoaderUtil
.
class
.
getClassLoader
();
}
return
cl
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment