sonatype-lift[bot] commented on code in PR #1682:
URL: https://github.com/apache/solr/pull/1682#discussion_r1214594404


##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaZkVersionAPI.java:
##########
@@ -0,0 +1,69 @@
+package org.apache.solr.handler.admin.api;
+
+import static 
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.lang.invoke.MethodHandles;
+import javax.inject.Inject;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.cloud.ZkSolrResourceLoader;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.schema.ManagedIndexSchema;
+import org.apache.solr.schema.ZkIndexSchemaReader;
+import org.apache.solr.security.PermissionNameProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/{a:cores|collections}/{collectionName}/schema")
+public class GetSchemaZkVersionAPI extends JerseyResource {
+
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  private SolrCore solrCore;
+
+  @Inject
+  public GetSchemaZkVersionAPI(SolrCore solrCore) {
+    this.solrCore = solrCore;
+  }
+
+  @GET
+  @Path("/zkversion")
+  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML, 
BINARY_CONTENT_TYPE_V2})
+  @PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
+  public SchemaZkVersionResponse getSchemaZkVersion(
+      @DefaultValue("-1") @QueryParam("refreshIfBelowVersion") Integer 
refreshIfBelowVersion)
+      throws Exception {
+    final SchemaZkVersionResponse response =
+        instantiateJerseyResponse(SchemaZkVersionResponse.class);
+    int zkVersion = -1;
+    if (solrCore.getLatestSchema() instanceof ManagedIndexSchema) {
+      ManagedIndexSchema managed = (ManagedIndexSchema) 
solrCore.getLatestSchema();
+      zkVersion = managed.getSchemaZkVersion();
+      if (refreshIfBelowVersion != -1 && zkVersion < refreshIfBelowVersion) {
+        log.info(

Review Comment:
   <picture><img alt="14% of developers fix this issue" 
src="https://lift.sonatype.com/api/commentimage/fixrate/14/display.svg";></picture>
   
   
<b>*[CRLF_INJECTION_LOGS](https://find-sec-bugs.github.io/bugs.htm#CRLF_INJECTION_LOGS):</b>*
  This use of 
org/slf4j/Logger.info(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V 
might be used to include CRLF characters into log messages
   
   ---
   
   <details><summary>ℹ️ Expand to see all <b>@sonatype-lift</b> 
commands</summary>
   
   You can reply with the following commands. For example, reply with 
***@sonatype-lift ignoreall*** to leave out all findings.
   | **Command** | **Usage** |
   | ------------- | ------------- |
   | `@sonatype-lift ignore` | Leave out the above finding from this PR |
   | `@sonatype-lift ignoreall` | Leave out all the existing findings from this 
PR |
   | `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified 
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
   
   **Note:** When talking to LiftBot, you need to **refresh** the page to see 
its response.
   <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) 
to add LiftBot to another repo.</sub></details>
   
   



-- 
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

Reply via email to