gerlowskija commented on code in PR #1412:
URL: https://github.com/apache/solr/pull/1412#discussion_r1129760918


##########
solr/core/src/java/org/apache/solr/jersey/SolrJacksonMapper.java:
##########
@@ -18,15 +18,44 @@
 package org.apache.solr.jersey;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonGenerator;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Provider;
+import org.apache.solr.common.util.NamedList;
 
 /** Customizes the ObjectMapper settings used for 
serialization/deserialization in Jersey */
+@SuppressWarnings("rawtypes")
 @Provider
 public class SolrJacksonMapper implements ContextResolver<ObjectMapper> {
   @Override
   public ObjectMapper getContext(Class<?> type) {
-    return new 
ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+    final SimpleModule customTypeModule = new SimpleModule();
+    customTypeModule.addSerializer(new NamedListSerializer(NamedList.class));
+
+    return new ObjectMapper()
+        .setSerializationInclusion(JsonInclude.Include.NON_NULL)
+        .registerModule(customTypeModule);
+  }
+
+  public static class NamedListSerializer extends StdSerializer<NamedList> {
+
+    public NamedListSerializer() {
+      this(null);
+    }
+
+    public NamedListSerializer(Class<NamedList> nlClazz) {
+      super(nlClazz);
+    }
+
+    @Override
+    public void serialize(NamedList value, JsonGenerator gen, 
SerializerProvider provider)
+        throws IOException {
+      gen.writeObject(value.asShallowMap());

Review Comment:
   > NamedList.shallowMap looks trivial but the implementations of several of 
its methods call NamedList.asMap which is not
   
   Yeah, I'd picked the shallow-map approach because it looked reasonably 
trivial, but point well taken about the `asMap` usage.  I suspect there's 
something that could be done with the MapWriter interface, but I couldn't get 
it working and eventually settled for what you see here.



##########
solr/core/src/java/org/apache/solr/jersey/SubResponseAccumulatingJerseyResponse.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Represents API responses composed of the responses of various sub-requests.
+ *
+ * <p>Many Solr APIs, particularly those historically reliant on overseer 
processing, return a
+ * response to the user that is composed in large part of the responses from 
all sub-requests made
+ * during the APIs execution. (e.g. the collection-deletion response itself 
contains the responses
+ * from the 'UNLOAD' call send to each core.) This class encapsulates those 
responses as possible.
+ */
+public class SubResponseAccumulatingJerseyResponse extends SolrJerseyResponse {
+
+  @JsonProperty("requestid")
+  public String requestId;

Review Comment:
   Not 'rid' related at all, though the overlap in terminology is definitely 
confusing and makes it seem that way.
   
   This is about the `async` parameter that some collection-admin APIs take to 
run commands asynchronously. 
    Today, if you make a collection-admin request with an `async` param, Solr 
will return a mostly blank response with only this 'requestid' field set 
(echoing back the `async` value you passed in).



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