gus-asf commented on code in PR #3997: URL: https://github.com/apache/solr/pull/3997#discussion_r2659305202
########## solr/core/src/java/org/apache/solr/servlet/EssentialSolrRequestFilter.java: ########## @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.servlet; + +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import org.apache.solr.common.util.SuppressForbidden; +import org.apache.solr.logging.MDCLoggingContext; +import org.apache.solr.logging.MDCSnapshot; +import org.apache.solr.request.SolrRequestInfo; +import org.apache.solr.util.RTimerTree; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Servlet Filter to set up and tear down a various things that downstream code in solr relies on. + * It is expected that solr will fail to function as intended without the conditions initialized in + * this filter. Before adding anything to this filter ask yourself if a user could run without the + * feature you are adding (either with an alternative implementation or without it at all to reduce + * cpu/memory/dependencies). If it is not essential, it should have its own separate filter. Also, + * please include a comment indicating why the thing added is essential. + */ +public class EssentialSolrRequestFilter extends CoreContainerAwareHttpFilter { + + // Best to put constant here because solr is not supposed to be functional (or compile) + // without this filter. + public static final String CORE_CONTAINER_REQUEST_ATTRIBUTE = "org.apache.solr.CoreContainer"; Review Comment: Ah took me a moment, but I remember why I didn't do that. I had feared that perhaps the HttpRequest was accessible from one or more of our key plugin types, but your question made me go verify if that was true and I'm happy to have found that that fear was unfounded, so there's no risk that plugin authors (except perhaps anyone who wrote an auth plugin) has discovered and relied on that attribute (which has been in the request attributes since SOLR-4265 in 2013). However, now that I've reassured myself I agree with your suggestion, and no longer worry that it needs to remain constant for all time even if someday a package changes etc. TLDR: will fix :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
