Apache Solr open-source search software
SOLR-15718 Remove backcompat feature solr.useUnsafeOverseerResponse (#371)
Jan Høydahl22e2953d2fbd
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex fb82b6060df..62063e18a47 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -56,7 +56,7 @@ Improvementscause. This capability is now also present on Windows. Before, with bin/solr but notbin/solr.cmd, Solr would execute a script that killed the Solr pid, leaving a very small timewindow where Solr would continue to execute in an unpredictable state. (Shawn Heisey, Kevin Risden)-+* SOLR-15478: A v2 equivalent of CLUSTERSTATUS command is now available at `GET /api/cluster`. Collection listing,previously at this path, can still be accessed at `GET /api/collections`. (Joshua Ouma via Jason Gerlowski)@@ -109,6 +109,8 @@ Other Changes* SOLR-16467: Upgrade semver4j to 2.2.0 to fix failures with some locales (Kevin Risden)+* SOLR-15718: Remove backcompat feature solr.useUnsafeOverseerResponse (janhoy)+================== 9.1.0 ==================New Featuresdiff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerSolrResponseSerializer.java b/solr/core/src/java/org/apache/solr/cloud/OverseerSolrResponseSerializer.javaindex dc9033bc189..68dfce3b1b0 100644--- a/solr/core/src/java/org/apache/solr/cloud/OverseerSolrResponseSerializer.java+++ b/solr/core/src/java/org/apache/solr/cloud/OverseerSolrResponseSerializer.java@@ -18,7 +18,6 @@ package org.apache.solr.cloud;import java.io.IOException;import java.util.Objects;-import org.apache.solr.client.solrj.SolrResponse;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.util.NamedList;@@ -35,12 +34,8 @@ public class OverseerSolrResponseSerializer {* org.apache.solr.common.util.JavaBinCodec#writeVal}* </ul>*/- @SuppressWarnings("deprecation")public static byte[] serialize(OverseerSolrResponse responseObject) {Objects.requireNonNull(responseObject);- if (useUnsafeSerialization()) {- return SolrResponse.serializable(responseObject);- }try {return Utils.toJavabin(responseObject.getResponse()).readAllBytes();} catch (IOException | RuntimeException e) {@@ -49,19 +44,6 @@ public class OverseerSolrResponseSerializer {}}- static boolean useUnsafeSerialization() {- String useUnsafeOverseerResponse = System.getProperty("solr.useUnsafeOverseerResponse");- return useUnsafeOverseerResponse != null && ("true".equals(useUnsafeOverseerResponse));- }-- static boolean useUnsafeDeserialization() {- String useUnsafeOverseerResponse = System.getProperty("solr.useUnsafeOverseerResponse");- return useUnsafeOverseerResponse != null- && ("true".equals(useUnsafeOverseerResponse)- || "deserialization".equals(useUnsafeOverseerResponse));- }-- @SuppressWarnings("deprecation")public static OverseerSolrResponse deserialize(byte[] responseBytes) {Objects.requireNonNull(responseBytes);try {@@ -69,9 +51,6 @@ public class OverseerSolrResponseSerializer {NamedList<Object> response = (NamedList<Object>) Utils.fromJavabin(responseBytes);return new OverseerSolrResponse(response);} catch (IOException | RuntimeException e) {- if (useUnsafeDeserialization()) {- return (OverseerSolrResponse) SolrResponse.deserialize(responseBytes);- }throw new SolrException(ErrorCode.SERVER_ERROR, "Exception deserializing response from Javabin", e);}diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerSolrResponseUnsafeSerializationTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerSolrResponseUnsafeSerializationTest.javadeleted file mode 100644index c635100b7ca..00000000000--- a/solr/core/src/test/org/apache/solr/cloud/OverseerSolrResponseUnsafeSerializationTest.java+++ /dev/null@@ -1,66 +0,0 @@-/*- * 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.cloud;--import org.junit.AfterClass;-import org.junit.BeforeClass;--public class OverseerSolrResponseUnsafeSerializationTest extends OverseerSolrResponseTest {-- @BeforeClass- public static void setUpClass() {- System.setProperty("solr.useUnsafeOverseerResponse", "true");- }-- @AfterClass- public static void tearDownClass() {- System.clearProperty("solr.useUnsafeOverseerResponse");- }-- public void testUnsafeSerializationToggles() {- assertToggles("true", true, true);- assertToggles("deserialization", false, true);- assertToggles(null, false, false); // By default, don't use unsafe- assertToggles("foo", false, false);- assertToggles("false", false, false);- assertToggles("serialization", false, false); // This is not an option- }-- private void assertToggles(- String propertyValue, boolean serializationEnabled, boolean deserializationEnabled) {- String previousValue = System.getProperty("solr.useUnsafeOverseerResponse");- try {- if (propertyValue == null) {- System.clearProperty("solr.useUnsafeOverseerResponse");- } else {- System.setProperty("solr.useUnsafeOverseerResponse", propertyValue);- }- assertEquals(- "Unexpected serialization toggle for value: " + propertyValue,- serializationEnabled,- OverseerSolrResponseSerializer.useUnsafeSerialization());- assertEquals(- "Unexpected serialization toggle for value: " + propertyValue,- deserializationEnabled,- OverseerSolrResponseSerializer.useUnsafeDeserialization());- } finally {- if (previousValue != null) {- System.setProperty("solr.useUnsafeOverseerResponse", previousValue);- }- }- }-}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.javaindex 17c9e42d490..c33269c8cca 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java@@ -16,17 +16,12 @@*/package org.apache.solr.client.solrj;-import java.io.ByteArrayInputStream;-import java.io.ByteArrayOutputStream;import java.io.IOException;-import java.io.ObjectInputStream;-import java.io.ObjectOutputStream;import java.io.Serializable;import org.apache.solr.common.MapWriter;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.util.NamedList;-import org.apache.solr.common.util.SuppressForbidden;/*** @since solr 1.3@@ -60,29 +55,4 @@ public abstract class SolrResponse implements Serializable, MapWriter {rspCode != null && rspCode != -1 ? ErrorCode.getErrorCode(rspCode) : ErrorCode.SERVER_ERROR;return new SolrException(errorCode, (String) exp.get("msg"));}-- @SuppressForbidden(reason = "XXX: security hole")- @Deprecated- public static byte[] serializable(SolrResponse response) {- try {- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();- ObjectOutputStream outputStream = new ObjectOutputStream(byteStream);- outputStream.writeObject(response);- return byteStream.toByteArray();- } catch (Exception e) {- throw new SolrException(ErrorCode.SERVER_ERROR, e);- }- }-- @SuppressForbidden(reason = "XXX: security hole")- @Deprecated- public static SolrResponse deserialize(byte[] bytes) {- try {- ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);- ObjectInputStream inputStream = new ObjectInputStream(byteStream);- return (SolrResponse) inputStream.readObject();- } catch (Exception e) {- throw new SolrException(ErrorCode.SERVER_ERROR, e);- }- }}