risdenk commented on code in PR #975: URL: https://github.com/apache/solr/pull/975#discussion_r960824509
########## solr/core/src/java/org/apache/solr/handler/SchemaHandler.java: ########## @@ -333,6 +330,13 @@ public Collection<Api> getApis() { return apis; } + @Override + public Collection<Class<? extends JerseyResource>> getJerseyResources() { + final List<Class<? extends JerseyResource>> jerseyResources = new ArrayList<>(); + jerseyResources.add(SchemaNameAPI.class); + return jerseyResources; Review Comment: Possibly use `List.of` - https://docs.oracle.com/javase/9/docs/api/java/util/List.html#of-E- ########## solr/core/src/test/org/apache/solr/handler/admin/api/SchemaNameAPITest.java: ########## @@ -0,0 +1,89 @@ +/* + * 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.handler.admin.api; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.client.solrj.response.schema.SchemaResponse; +import org.apache.solr.common.util.NamedList; +import org.apache.solr.core.SolrCore; +import org.apache.solr.handler.SchemaHandler; +import org.apache.solr.handler.api.V2ApiUtils; +import org.apache.solr.schema.IndexSchema; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +// These tests create SchemaNameAPI instances directly, which is valuable. But they don't test that +// the JAX-RS annotations +// or resource-matching is correct. Should we have other tests to exercise that, or is relying on +// Solr's existing +// testing of this API sufficient? Review Comment: nit: wrapping of the comment seems weird. most likely spotless reformatted this ########## solr/core/build.gradle: ########## @@ -182,6 +191,10 @@ dependencies { testImplementation 'junit:junit' testImplementation 'org.hamcrest:hamcrest' + testImplementation 'org.glassfish.jersey.test-framework:jersey-test-framework-core:2.35' + testImplementation 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.35' Review Comment: Should these version specifications be here? ########## solr/core/src/java/org/apache/solr/api/V2HttpCall.java: ########## @@ -362,14 +363,15 @@ private void invokeJerseyRequest(CoreContainer cores, SolrCore core, Application // Set properties that may be used by Jersey filters downstream containerRequest.setProperty(SOLR_QUERY_REQUEST_KEY, solrReq); - containerRequest.setProperty(SolrRequestAuthorizer.CORE_CONTAINER_PROP_NAME, cores); - containerRequest.setProperty(SolrRequestAuthorizer.HTTP_SERVLET_REQ_PROP_NAME, req); - containerRequest.setProperty(SolrRequestAuthorizer.REQUEST_TYPE_PROP_NAME, requestType); - containerRequest.setProperty(SolrRequestAuthorizer.SOLR_PARAMS_PROP_NAME, queryParams); - containerRequest.setProperty(SolrRequestAuthorizer.COLLECTION_LIST_PROP_NAME, collectionsList); - containerRequest.setProperty(SolrRequestAuthorizer.HTTP_SERVLET_RSP_PROP_NAME, response); + containerRequest.setProperty(SOLR_QUERY_RESPONSE_KEY, rsp); Review Comment: I think the point being for consistency with the lines below this? ########## solr/core/src/java/org/apache/solr/jersey/ApplicationEventLogger.java: ########## @@ -0,0 +1,51 @@ +/* + * 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.jersey; + +import java.lang.invoke.MethodHandles; +import org.glassfish.jersey.server.monitoring.ApplicationEvent; +import org.glassfish.jersey.server.monitoring.ApplicationEventListener; +import org.glassfish.jersey.server.monitoring.RequestEvent; +import org.glassfish.jersey.server.monitoring.RequestEventListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Logs out application-level information useful for troubleshooting Jersey development. + * + * @see RequestEventLogger + */ +public class ApplicationEventLogger implements ApplicationEventListener { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private volatile long requestCount = 0; Review Comment: Could use `AtomicLong` - https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html ########## solr/core/src/java/org/apache/solr/jersey/RequestEventLogger.java: ########## @@ -0,0 +1,49 @@ +/* + * 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.jersey; + +import java.lang.invoke.MethodHandles; +import org.glassfish.jersey.server.monitoring.RequestEvent; +import org.glassfish.jersey.server.monitoring.RequestEventListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Logs out request-specific information useful for troubleshooting Jersey development. + * + * @see ApplicationEventLogger + */ +public class RequestEventLogger implements RequestEventListener { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private volatile long requestCount; Review Comment: Could use `AtomicLong` - https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html ########## solr/core/src/java/org/apache/solr/jersey/PostRequestDecorationFilter.java: ########## @@ -0,0 +1,60 @@ +/* + * 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.jersey; + +import static org.apache.solr.jersey.RequestContextConstants.SOLR_QUERY_REQUEST_KEY; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import org.apache.solr.core.SolrCore; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.request.SolrRequestHandler; +import org.apache.solr.response.SolrQueryResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Applies standard post-processing decorations to a {@link SolrJerseyResponse} that are needed on + * all responses. + * + * @see SolrCore#postDecorateResponse(SolrRequestHandler, SolrQueryRequest, SolrQueryResponse) + */ +public class PostRequestDecorationFilter implements ContainerResponseFilter { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @Override + public void filter( + ContainerRequestContext requestContext, ContainerResponseContext responseContext) + throws IOException { + final SolrQueryRequest solrQueryRequest = + (SolrQueryRequest) requestContext.getProperty(SOLR_QUERY_REQUEST_KEY); + if (!responseContext.hasEntity() + || !SolrJerseyResponse.class.isInstance(responseContext.getEntity())) { + log.debug("Skipping QTime assignment because response was not a SolrJerseyResponse"); + return; + } + + log.info("JEGERLOW: Setting QTime"); Review Comment: Nit: leftover logging? -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org