Hello!
Due to some limitations of Sonarqube, and inability to get hold of the source code for the EE version to apply a patch (working patch on CE version); I’m a little forced to write a plugin.
I am starting very small with a ServletFilter and just logging the current request URL from the servlet filter.
I tried with and without doGetPattern overloaded and it makes no change: the logging occurs randomly.
The content of the class can be found below. And we’re using the latest current LTS version of Sonarqube : 8.9.9.
Is this a know bug in Sonarqube? What is curious to me is that with TRACE level enabled, I can see the class UserSessionFilter sonarqube/UserSessionFilter.java at 5fb0f5edafa247fafe76f50f24226528d6774638 · SonarSource/sonarqube · GitHub which does log the current request fine for all incoming requests
.
.
.
import org.sonar.api.web.ServletFilter;
public class UserHeader extends ServletFilter {
private static final Logger LOG = Loggers.get(UserHeader.class);
// private static final String ACCESS_LOG_LOGIN = "LOGIN";
@Override
public void init(FilterConfig filterConfig) throws ServletException {
LOG.info("Loaded " + getClass().getName());
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
LOG.info("{} serves {}", Thread.currentThread(), ((HttpServletRequest) request).getRequestURI());
/*
String userId = (String) ((HttpServletRequest) request).getAttribute(ACCESS_LOG_LOGIN);
((HttpServletResponse) response).setHeader(ACCESS_LOG_LOGIN, userId);
*/
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}