Skip to content

Commit b6ac7bb

Browse files
tulinkryVladimir Kotal
authored andcommitted
Hotfix for non-deterministic results for partial index
Under some circumstances the configuration view per each thread can become desynchronized when using partial index. The issue itself should be tackled in more robust way. approaches #2382
1 parent 4db8405 commit b6ac7bb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

opengrok-web/src/main/java/org/opengrok/web/AuthorizationFilter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.servlet.http.HttpServletRequest;
3535
import javax.servlet.http.HttpServletResponse;
3636
import org.opengrok.indexer.configuration.Project;
37+
import org.opengrok.indexer.configuration.RuntimeEnvironment;
3738
import org.opengrok.indexer.logger.LoggerFactory;
3839
import org.opengrok.indexer.web.PageConfig;
3940
import org.opengrok.web.api.v1.RestApp;
@@ -51,6 +52,10 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
5152
HttpServletRequest httpReq = (HttpServletRequest) sr;
5253
HttpServletResponse httpRes = (HttpServletResponse) sr1;
5354

55+
// This way we trigger refresh for the current configuration value.
56+
// Hotfix for #2382
57+
RuntimeEnvironment.getInstance().register();
58+
5459
// All RESTful API requests are allowed for now (also see LocalhostFilter).
5560
// The /search endpoint will go through authorization via SearchEngine.search()
5661
// so does not have to be exempted here.
@@ -73,7 +78,7 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
7378
} else {
7479
LOGGER.log(Level.INFO, "Access denied for URI: {0}", httpReq.getRequestURI());
7580
}
76-
81+
7782
/**
7883
* Add the request to the statistics. This is called just once for a
7984
* single request otherwise the next filter will count the same
@@ -86,12 +91,12 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
8691
config.getEnv().getStatistics().addRequest("requests_forbidden");
8792
config.getEnv().getStatistics().addRequestTime("requests_forbidden",
8893
System.currentTimeMillis() - processTime);
89-
94+
9095
if (!config.getEnv().getConfiguration().getForbiddenIncludeFileContent(false).isEmpty()) {
9196
sr.getRequestDispatcher("/eforbidden").forward(sr, sr1);
9297
return;
9398
}
94-
99+
95100
httpRes.sendError(HttpServletResponse.SC_FORBIDDEN, "Access forbidden");
96101
return;
97102
}

0 commit comments

Comments
 (0)