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


##########
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")

Review Comment:
   Did you try to fix this or too tricky?  These are annoying



##########
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:
   I suspect if benchmarks are done, this is going to be revisited to be more 
efficient.  That NamedList.shallowMap looks trivial but the implementations of 
several of its methods call NamedList.asMap which is not.  Fine for now I guess.
   CC @noblepaul 



##########
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:
   Isn't the requestId here the same as "rid" which is only used in logging?  
But maybe not because it's a response JSON property?



##########
solr/core/src/test/org/apache/solr/handler/admin/api/DeleteCollectionAPITest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.handler.admin.api;
+
+import static org.apache.solr.cloud.Overseer.QUEUE_OPERATION;
+import static 
org.apache.solr.common.params.CollectionAdminParams.FOLLOW_ALIASES;
+import static org.apache.solr.common.params.CollectionParams.NAME;
+import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+
+import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.cloud.ZkNodeProps;
+import org.hamcrest.MatcherAssert;
+import org.junit.Test;
+
+/** Unit tests for {@link DeleteCollectionAPI} */
+public class DeleteCollectionAPITest extends SolrTestCaseJ4 {
+
+  @Test
+  public void testConstructsValidOverseerMessage() {
+    // Only required properties provided
+    {
+      final ZkNodeProps message =
+          DeleteCollectionAPI.createRemoteMessage("someCollName", null, null);

Review Comment:
   Sigh... one day if we ever want to remove the Overseer fully, I see here an 
ever increasing number of tests that assume its existence.  Yeah we've spoken 
about this, just reading this test with a heavy sigh.



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