Tolerate API changes between Tomcat 7 and Tomcat 8
See gh-6053
This commit is contained in:
parent
a5ad2b33ab
commit
29ac6fc154
|
|
@ -98,7 +98,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
|||
|
||||
Context context = findContext();
|
||||
try {
|
||||
ContextBindings.bindClassLoader(context, context.getNamingToken(),
|
||||
ContextBindings.bindClassLoader(context, getNamingToken(context),
|
||||
getClass().getClassLoader());
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
|
|
@ -191,7 +191,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
|||
}
|
||||
finally {
|
||||
Context context = findContext();
|
||||
ContextBindings.unbindClassLoader(context, context.getNamingToken(),
|
||||
ContextBindings.unbindClassLoader(context, getNamingToken(context),
|
||||
getClass().getClassLoader());
|
||||
}
|
||||
}
|
||||
|
|
@ -312,4 +312,15 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
|||
return this.tomcat;
|
||||
}
|
||||
|
||||
private Object getNamingToken(Context context) {
|
||||
try {
|
||||
return context.getNamingToken();
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
// Use the context itself on Tomcat 7
|
||||
return context;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue