From 301223915d2517aed1407b49b6ae5590914cddb8 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Wed, 4 Oct 2017 19:54:44 +1030 Subject: [PATCH] precommit errors --- .../solr/cloud/autoscaling/AutoScaling.java | 5 +++-- .../solr/cloud/autoscaling/TriggerBase.java | 2 -- .../cloud/autoscaling/TriggerEventQueue.java | 5 +++-- .../solr/cloud/overseer/ReplicaMutator.java | 1 - .../org/apache/solr/core/CoreContainer.java | 1 - .../admin/AutoscalingHistoryHandler.java | 19 ++++++++++++++++++- .../java/org/apache/solr/util/IdUtils.java | 16 ++++++++++++++++ .../AutoAddReplicasPlanActionTest.java | 2 ++ .../autoscaling/ComputePlanActionTest.java | 4 ++-- .../admin/AutoscalingHistoryHandlerTest.java | 19 ++++++++++++++++--- 10 files changed, 60 insertions(+), 14 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScaling.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScaling.java index bd74c8458fc..ef0cfda6ae3 100644 --- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScaling.java +++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScaling.java @@ -21,6 +21,7 @@ import java.io.Closeable; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Objects; import com.google.common.base.Preconditions; import org.apache.lucene.store.AlreadyClosedException; @@ -120,8 +121,8 @@ public class AutoScaling { private boolean isClosed = false; public TriggerFactory(CoreContainer coreContainer, ZkController zkController) { - Preconditions.checkNotNull(coreContainer); - Preconditions.checkNotNull(zkController); + Objects.requireNonNull(coreContainer); + Objects.requireNonNull(zkController); this.coreContainer = coreContainer; this.zkController = zkController; } diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java index 7aff8464c22..45d0f89dfd1 100644 --- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java +++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java @@ -17,9 +17,7 @@ package org.apache.solr.cloud.autoscaling; import java.lang.invoke.MethodHandles; -import java.util.Arrays; import java.util.Map; -import java.util.TreeMap; import org.apache.solr.common.cloud.SolrZkClient; import org.apache.solr.common.cloud.ZkStateReader; diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerEventQueue.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerEventQueue.java index 4030cd29cc7..3b22a3cd408 100644 --- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerEventQueue.java +++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerEventQueue.java @@ -17,6 +17,7 @@ package org.apache.solr.cloud.autoscaling; import java.lang.invoke.MethodHandles; +import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.solr.client.solrj.cloud.autoscaling.TriggerEventType; @@ -69,7 +70,7 @@ public class TriggerEventQueue extends ZkDistributedQueue { Map map = (Map) Utils.fromJSON(data); return fromMap(map); } catch (Exception e) { - LOG.warn("Invalid event data, ignoring: " + new String(data)); + LOG.warn("Invalid event data, ignoring: " + new String(data, StandardCharsets.UTF_8)); continue; } } @@ -91,7 +92,7 @@ public class TriggerEventQueue extends ZkDistributedQueue { Map map = (Map) Utils.fromJSON(data); return fromMap(map); } catch (Exception e) { - LOG.warn("Invalid event data, ignoring: " + new String(data)); + LOG.warn("Invalid event data, ignoring: " + new String(data, StandardCharsets.UTF_8)); continue; } } diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java index fad5d961dbc..82d106df901 100644 --- a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java +++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java @@ -37,7 +37,6 @@ import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkStateReader; -import org.apache.solr.common.params.CoreAdminParams; import org.apache.solr.common.util.Utils; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index c3ce0ed4011..e1e5a01fc85 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -105,7 +105,6 @@ import org.apache.solr.security.HttpClientBuilderPlugin; import org.apache.solr.security.PKIAuthenticationPlugin; import org.apache.solr.security.SecurityPluginHolder; import org.apache.solr.update.SolrCoreState; -import org.apache.solr.update.UpdateLog; import org.apache.solr.update.UpdateShardHandler; import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.stats.MetricUtils; diff --git a/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java index 0e3440b1a08..1c568d6d93a 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java @@ -1,7 +1,24 @@ +/* + * 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; import java.lang.invoke.MethodHandles; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -99,7 +116,7 @@ public class AutoscalingHistoryHandler extends RequestHandlerBase implements Per String[] values = params.remove(e.getKey()); if (values != null) { for (String value : values) { - params.add(CommonParams.FQ, String.format(e.getValue(), value)); + params.add(CommonParams.FQ, String.format(Locale.ROOT, e.getValue(), value)); } } } diff --git a/solr/core/src/java/org/apache/solr/util/IdUtils.java b/solr/core/src/java/org/apache/solr/util/IdUtils.java index 1ad9cf8fc24..a6ea7d2907b 100644 --- a/solr/core/src/java/org/apache/solr/util/IdUtils.java +++ b/solr/core/src/java/org/apache/solr/util/IdUtils.java @@ -1,3 +1,19 @@ +/* + * 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.util; import java.util.concurrent.TimeUnit; diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java index 4a0495d6615..2259c404a7c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java @@ -36,6 +36,7 @@ import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; +import org.apache.solr.common.util.SuppressForbidden; import org.apache.solr.util.TimeOut; import org.junit.BeforeClass; import org.junit.Test; @@ -147,6 +148,7 @@ public class AutoAddReplicasPlanActionTest extends SolrCloudTestCase{ } } + @SuppressForbidden(reason = "Needs currentTimeMillis to create unique id") private List getOperations(JettySolrRunner actionJetty, String lostNodeName) { AutoAddReplicasPlanAction action = new AutoAddReplicasPlanAction(); TriggerEvent lostNode = new NodeLostTrigger.NodeLostEvent(TriggerEventType.NODELOST, ".auto_add_replicas", Collections.singletonList(System.currentTimeMillis()), Collections.singletonList(lostNodeName)); diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/ComputePlanActionTest.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/ComputePlanActionTest.java index d9b88b5adf1..9f1e5de4059 100644 --- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/ComputePlanActionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/ComputePlanActionTest.java @@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import com.google.common.base.Charsets; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.cloud.autoscaling.TriggerEventType; import org.apache.solr.client.solrj.embedded.JettySolrRunner; @@ -47,6 +46,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest; import static org.apache.solr.common.params.CollectionParams.CollectionAction.MOVEREPLICA; @@ -79,7 +79,7 @@ public class ComputePlanActionTest extends SolrCloudTestCase { actionContextPropsRef.set(null); // remove everything from autoscaling.json in ZK - zkClient().setData(ZkStateReader.SOLR_AUTOSCALING_CONF_PATH, "{}".getBytes(Charsets.UTF_8), true); + zkClient().setData(ZkStateReader.SOLR_AUTOSCALING_CONF_PATH, "{}".getBytes(UTF_8), true); if (cluster.getJettySolrRunners().size() > NODE_COUNT) { // stop some to get to original state diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java index 56c920ed24a..09f5edc2e19 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java @@ -1,3 +1,19 @@ +/* + * 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; import java.lang.invoke.MethodHandles; @@ -34,9 +50,6 @@ import org.slf4j.LoggerFactory; import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest; -/** - * - */ @LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.cloud.Overseer=DEBUG;org.apache.solr.cloud.overseer=DEBUG;") public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());