-
Quality Risk
-
Resolution: Done
-
Major
-
None
-
None
I've noticed that names of additional config sources provided by EAP7-1386 are always:
null:null:ServletConfigSource null:null:FilterConfigSource null:ServletContextConfigSource
I've tried to enhance the https://www.geeksforgeeks.org/difference-between-servletconfig-and-servletcontext-in-java-servlet/ example with MP config, to get the different names
Servlet additions:
System.out.println("-------------------------------------"); System.out.println("Servlet context name: " + getServletContext().getServletContextName()); System.out.println("Servlet virtual server name: " + getServletContext().getVirtualServerName()); System.out.println("Servlet name from servlet config: " + getServletConfig().getServletName()); System.out.println("Servlet name: " + getServletName()); System.out.println("Servlet info: " + getServletInfo()); ConfigProvider.getConfig().getConfigSources().forEach(configSource -> { System.out.println("================================="); System.out.println(configSource.getName()); System.out.println(configSource.getOrdinal()); System.out.println("Property names: " + configSource.getPropertyNames().stream().collect(Collectors.joining(", "))); }); System.out.println("-------------------------------------");
web.xml addition
<web-app> + <display-name>test</display-name> ...
server output:
------------------------------------- Servlet context name: test Servlet virtual server name: default-host Servlet name from servlet config: recruiter Servlet name: recruiter Servlet info: ================================= SysPropConfigSource 400 Property names: [Standalone], awt.toolkit, java.specification.version ... ================================= EnvConfigSource 300 Property names: PATH, ... ================================= null:null:ServletConfigSource 60 Property names: ================================= null:null:FilterConfigSource 50 Property names: ================================= null:ServletContextConfigSource 40 Property names: -------------------------------------
Looking into sources https://github.com/resteasy/Resteasy/pull/2250/files#diff-c4301c90ec3913499dfd71e2507e471bR51
@Override public String getName() { if (name == null) { synchronized(this) { if (name == null) { ServletContext servletContext = ResteasyProviderFactory.getContextData(ServletContext.class); ServletConfig servletConfig = ResteasyProviderFactory.getContextData(ServletConfig.class); StringBuilder sb = new StringBuilder(); name = sb.append(servletContext != null ? servletContext.getServletContextName() : null).append(":") .append(servletConfig != null ? servletConfig.getServletName() : null) .append(":ServletConfigSource").toString(); } } } return name; }
My simple-minded expectation would be that the config sources name will use the fields provided in web.xml.
Reproduce:
- start standalone server
- deploy [^source-names.war]
- curl http://localhost:8080/source-names/servlet1
- see server logs
See [^source-names.zip] for sources.