You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/09/01 09:13:59 UTC

[GitHub] [solr] sonatype-lift[bot] commented on a change in pull request #254: Solr 15581

sonatype-lift[bot] commented on a change in pull request #254:
URL: https://github.com/apache/solr/pull/254#discussion_r699665335



##########
File path: solr/benchmark/src/java/org/apache/solr/bench/BaseBenchState.java
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.bench;
+
+import com.sun.management.HotSpotDiagnosticMXBean;
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.SplittableRandom;
+import javax.management.MBeanServer;
+import org.apache.commons.io.FileUtils;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.infra.BenchmarkParams;
+
+@State(Scope.Benchmark)
+public class BaseBenchState {
+
+  private static final long RANDOM_SEED = 6624420638116043983L;
+
+  private static SplittableRandom random = new SplittableRandom(getInitRandomeSeed());
+
+  public static Long getRandomSeed() {
+    return random.split().nextLong();
+  }
+
+  public static boolean quietLog = Boolean.getBoolean("quietLog");
+
+  @SuppressForbidden(reason = "JMH uses std out for user output")
+  public static void log(String value) {
+    if (!quietLog) {
+      System.out.println((value.isEmpty() ? "" : "--> ") + value);
+    }
+  }
+
+  @Setup(Level.Trial)
+  public void doSetup(BenchmarkParams benchmarkParams) throws Exception {
+    System.setProperty("solr.log.name", benchmarkParams.id());
+  }
+
+  @TearDown(Level.Trial)
+  public static void doTearDown(BenchmarkParams benchmarkParams) throws Exception {
+    String heapDump = System.getProperty("dumpheap");
+    if (heapDump != null) {
+      File file = new File(heapDump);
+      FileUtils.deleteDirectory(file);
+      file.mkdirs();
+      File dumpFile = new File(file, benchmarkParams.id() + ".hprof");

Review comment:
       *PATH_TRAVERSAL_IN:*  This API (java/io/File.<init>(Ljava/io/File;Ljava/lang/String;)V) reads a file whose location might be specified by user input [(details)](https://find-sec-bugs.github.io/bugs.htm#PATH_TRAVERSAL_IN)
   (at-me [in a reply](https://help.sonatype.com/lift) with `help` or `ignore`)

##########
File path: solr/core/src/java/org/apache/solr/core/SolrCore.java
##########
@@ -828,6 +828,7 @@ void initIndex(boolean passOnPreviousState, boolean reload) throws IOException {
       try {
         writer = SolrIndexWriter.create(this, "SolrCore.initIndex", indexDir, getDirectoryFactory(), true,

Review comment:
       *THREAD_SAFETY_VIOLATION:*  Unprotected write. Non-private method `SolrCore.initIndex(...)` indirectly mutates container `core.SolrResourceLoader.classNameCache` via call to `Map.put(...)` outside of synchronization.
    Reporting because this access may occur on a background thread.
   (at-me [in a reply](https://help.sonatype.com/lift) with `help` or `ignore`)




-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org