mirror of https://github.com/apache/lucene.git
SOLR-11151: SolrInfoMBeanHandler.getDiff() ADD case non-functional: NPE when a bean value goes from null -> non-null
This commit is contained in:
parent
e95b48e12d
commit
615cc38b18
|
@ -391,6 +391,9 @@ Bug Fixes
|
|||
|
||||
* SOLR-11130: V2Request in SolrJ should return the correct collection name so that the request is forwarded to the
|
||||
correct node (noble)
|
||||
|
||||
* SOLR-11151: SolrInfoMBeanHandler.getDiff() ADD case non-functional: NPE when a bean value goes from null -> non-null.
|
||||
(Steve Rowe)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
|
|
@ -209,14 +209,16 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
|
|||
for(int i=0; i<ref.size(); i++) {
|
||||
String name = ref.getName(i);
|
||||
Object r = ref.getVal(i);
|
||||
Object n = now.remove(name);
|
||||
if(n == null) {
|
||||
if(r!=null) {
|
||||
out.add("REMOVE "+name, r);
|
||||
Object n = now.get(name);
|
||||
if (n == null) {
|
||||
if (r != null) {
|
||||
out.add("REMOVE " + name, r);
|
||||
now.remove(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
out.add(name, diffObject(r,n));
|
||||
else if (r != null) {
|
||||
out.add(name, diffObject(r, n));
|
||||
now.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,13 @@
|
|||
*/
|
||||
package org.apache.solr.handler.admin;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -26,6 +31,12 @@ import org.apache.solr.common.params.CommonParams;
|
|||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.ContentStreamBase;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.metrics.SolrCoreMetricManager;
|
||||
import org.apache.solr.metrics.SolrMetricManager;
|
||||
import org.apache.solr.metrics.SolrMetricReporter;
|
||||
import org.apache.solr.metrics.reporters.JmxObjectNameFactory;
|
||||
import org.apache.solr.metrics.reporters.SolrJmxReporter;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -82,6 +93,29 @@ public class MBeansHandlerTest extends SolrTestCaseJ4 {
|
|||
assertNotNull( nl.get("ADMIN").get("org.apache.solr.handler.admin.CollectionsHandler"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddedMBeanDiff() throws Exception {
|
||||
String xml = h.query(req(
|
||||
CommonParams.QT,"/admin/mbeans",
|
||||
"stats","true",
|
||||
CommonParams.WT,"xml"
|
||||
));
|
||||
|
||||
// Artificially convert a long value to a null, to trigger the ADD case in SolrInfoMBeanHandler.diffObject()
|
||||
xml = xml.replaceFirst("<long\\s+(name\\s*=\\s*\"ADMIN./admin/mbeans.totalTime\"\\s*)>[^<]*</long>", "<null $1/>");
|
||||
|
||||
LocalSolrQueryRequest req = lrf.makeRequest(
|
||||
CommonParams.QT,"/admin/mbeans",
|
||||
"stats","true",
|
||||
CommonParams.WT,"xml",
|
||||
"diff","true");
|
||||
req.setContentStreams(Collections.singletonList(new ContentStreamBase.StringStream(xml)));
|
||||
xml = h.query(req);
|
||||
|
||||
NamedList<NamedList<NamedList<Object>>> nl = SolrInfoMBeanHandler.fromXML(xml);
|
||||
assertNotNull(((NamedList)nl.get("ADMIN").get("/admin/mbeans").get("stats")).get("ADD ADMIN./admin/mbeans.totalTime"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXMLDiffWithExternalEntity() throws Exception {
|
||||
String file = getFile("mailing_lists.pdf").toURI().toASCIIString();
|
||||
|
|
Loading…
Reference in New Issue