Apache Solr open-source search software
SOLR-17441: MetricUtils: Skip Unreadable Properties (#2694)
Heythmee5c9bedf069
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 6f24dcfdadd..e458cca3956 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -140,6 +140,8 @@ Optimizations* SOLR-3913: Optimize PostTool to call just optimize when both commit and optimize requested. (Eric Pugh)+* SOLR-17441: Improve system metrics collection by skipping unreadable MXBean properties, making /admin/info/system calls faster (Haythem Khiri)+Bug Fixes---------------------* SOLR-12429: Uploading a configset with a symbolic link produces a IOException. Now a error message to user generated instead. (Eric Pugh)diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.javaindex 95b6d7556ad..71f240ac0a8 100644--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java@@ -35,6 +35,7 @@ import java.lang.invoke.MethodHandles;import java.lang.management.OperatingSystemMXBean;import java.lang.management.PlatformManagedObject;import java.lang.reflect.InvocationTargetException;+import java.lang.reflect.Method;import java.util.Collection;import java.util.HashMap;import java.util.List;@@ -787,19 +788,25 @@ public class MetricUtils {}});+ // if BeanInfo retrieval failed, return earlyif (beanInfo == null) {return;}for (final PropertyDescriptor desc : beanInfo.getPropertyDescriptors()) {- final String name = desc.getName();- // test if it works at alltry {- desc.getReadMethod().invoke(obj);+ Method readMethod = desc.getReadMethod();+ if (readMethod == null) {+ continue; // skip properties without a read method+ }++ final String name = desc.getName();+ // test if it works at all+ readMethod.invoke(obj);// worked - consume itfinal Gauge<?> gauge =() -> {try {- return desc.getReadMethod().invoke(obj);+ return readMethod.invoke(obj);} catch (InvocationTargetException ite) {// ignore (some properties throw UOE)return null;