mirror of https://github.com/apache/lucene.git
SOLR-7258: Forbid MessageFormat.format and MessageFormat single-arg constructor
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1667414 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fd8a588bc5
commit
8d64c08c1a
|
@ -70,7 +70,7 @@ public class NLS {
|
|||
String str = getLocalizedMessage(key, locale);
|
||||
|
||||
if (args.length > 0) {
|
||||
str = MessageFormat.format(str, args);
|
||||
str = new MessageFormat(str, Locale.ROOT).format(args);
|
||||
}
|
||||
|
||||
return str;
|
||||
|
|
|
@ -34,3 +34,7 @@ java.io.File#delete() @ use Files.delete for real exception, IOUtils.deleteFiles
|
|||
|
||||
@defaultMessage Use shuffle(List, Random) instead so that it can be reproduced
|
||||
java.util.Collections#shuffle(java.util.List)
|
||||
|
||||
@defaultMessage Construct MessageFormat(String pattern, String locale) and then use the format(String,Object...) method
|
||||
java.text.MessageFormat#format(java.lang.String,java.lang.Object[])
|
||||
java.text.MessageFormat#<init>(java.lang.String)
|
||||
|
|
|
@ -332,6 +332,9 @@ Other Changes
|
|||
|
||||
* SOLR-7246: Speed up BasicZkTest, TestManagedResourceStorage (Ramkumar Aiyengar)
|
||||
|
||||
* SOLR-7258: Forbid MessageFormat.format and MessageFormat single-arg constructor.
|
||||
(shalin)
|
||||
|
||||
================== 5.0.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
|
|||
import org.apache.lucene.search.join.BitDocIdSetFilter;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.handler.dataimport.config.ConfigNameConstants;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
|
@ -335,9 +336,9 @@ public class TestHierarchicalDocBuilder extends AbstractDataImportHandlerTestCas
|
|||
String children = createChildren(parentType, 0, depth, parentData, holder);
|
||||
|
||||
String rootFields = createFieldsList(FIELD_ID, "desc", "type_s");
|
||||
String rootEntity = MessageFormat.format(rootEntityTemplate, parentType, "SELECT * FROM " + parentType, rootFields, children);
|
||||
String rootEntity = StrUtils.formatString(rootEntityTemplate, parentType, "SELECT * FROM " + parentType, rootFields, children);
|
||||
|
||||
String config = MessageFormat.format(dataConfigTemplate, rootEntity);
|
||||
String config = StrUtils.formatString(dataConfigTemplate, rootEntity);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -398,7 +399,7 @@ public class TestHierarchicalDocBuilder extends AbstractDataImportHandlerTestCas
|
|||
List<Hierarchy> childData = createMockedIterator(childName, parentData, holder);
|
||||
|
||||
String subChildren = createChildren(childName, currentLevel + 1, maxLevel, childData, holder);
|
||||
String child = MessageFormat.format(childEntityTemplate, childName, select, fields, subChildren);
|
||||
String child = StrUtils.formatString(childEntityTemplate, childName, select, fields, subChildren);
|
||||
builder.append(child);
|
||||
builder.append('\n');
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
|
|||
import org.apache.solr.common.cloud.ZooKeeperException;
|
||||
import org.apache.solr.common.params.CollectionParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.common.util.URLUtil;
|
||||
import org.apache.solr.core.CloseHook;
|
||||
import org.apache.solr.core.CloudConfig;
|
||||
|
@ -2168,8 +2169,8 @@ public final class ZkController {
|
|||
log.warn("could not get stat");
|
||||
}
|
||||
|
||||
log.info(MessageFormat.format(errMsg, resourceLocation, znodeVersion));
|
||||
throw new ResourceModifiedInZkException(ErrorCode.CONFLICT, MessageFormat.format(errMsg, resourceLocation, znodeVersion) + ", retry.");
|
||||
log.info(StrUtils.formatString(errMsg, resourceLocation, znodeVersion));
|
||||
throw new ResourceModifiedInZkException(ErrorCode.CONFLICT, StrUtils.formatString(errMsg, resourceLocation, znodeVersion) + ", retry.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2183,8 +2184,8 @@ public final class ZkController {
|
|||
log.error(e.getMessage());
|
||||
|
||||
}
|
||||
log.info(MessageFormat.format(errMsg + " zkVersion= " + v, resourceLocation, znodeVersion));
|
||||
throw new ResourceModifiedInZkException(ErrorCode.CONFLICT, MessageFormat.format(errMsg, resourceLocation, znodeVersion) + ", retry.");
|
||||
log.info(StrUtils.formatString(errMsg + " zkVersion= " + v, resourceLocation, znodeVersion));
|
||||
throw new ResourceModifiedInZkException(ErrorCode.CONFLICT, StrUtils.formatString(errMsg, resourceLocation, znodeVersion) + ", retry.");
|
||||
} catch (ResourceModifiedInZkException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ConfigOverlay implements MapSerializable{
|
|||
private List<String> checkEditable(String propName, boolean isXPath, boolean failOnError) {
|
||||
LinkedList<String> hierarchy = new LinkedList<>();
|
||||
if(!isEditableProp(propName, isXPath,hierarchy)) {
|
||||
if(failOnError) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, MessageFormat.format( NOT_EDITABLE,propName));
|
||||
if(failOnError) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, StrUtils.formatString( NOT_EDITABLE,propName));
|
||||
else return null;
|
||||
}
|
||||
return hierarchy;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.lucene.analysis.util.ResourceLoader;
|
|||
import org.apache.lucene.analysis.util.ResourceLoaderAware;
|
||||
import org.apache.solr.cloud.CloudUtil;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.handler.RequestHandlerBase;
|
||||
import org.apache.solr.handler.component.SearchComponent;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
|
@ -415,7 +416,7 @@ public class PluginBag<T> implements AutoCloseable {
|
|||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "No public keys are available in ZK to verify signature for runtime lib " + name);
|
||||
}
|
||||
} else if (sig == null) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, MessageFormat.format("runtimelib {0} should be signed with one of the keys in ZK /keys/exe ", name));
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, StrUtils.formatString("runtimelib {0} should be signed with one of the keys in ZK /keys/exe ", name));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.OutputStream;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -135,7 +134,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
"size", payload.limit(),
|
||||
"blob", payload);
|
||||
verifyWithRealtimeGet(blobName, version, req, doc);
|
||||
log.info(MessageFormat.format("inserting new blob {0} ,size {1}, md5 {2}", doc.get("id"), String.valueOf(payload.limit()), md5));
|
||||
log.info(StrUtils.formatString("inserting new blob {0} ,size {1}, md5 {2}", doc.get("id"), String.valueOf(payload.limit()), md5));
|
||||
indexMap(req, rsp, doc);
|
||||
log.info(" Successfully Added and committed a blob with id {} and size {} ", id, payload.limit());
|
||||
|
||||
|
@ -159,7 +158,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
} else {
|
||||
String q = "blobName:{0}";
|
||||
if (version != -1) q = "id:{0}/{1}";
|
||||
QParser qparser = QParser.getParser(MessageFormat.format(q, blobName, version), "lucene", req);
|
||||
QParser qparser = QParser.getParser(StrUtils.formatString(q, blobName, version), "lucene", req);
|
||||
final TopDocs docs = req.getSearcher().search(qparser.parse(), 1, new Sort(new SortField("version", SortField.Type.LONG, true)));
|
||||
if (docs.totalHits > 0) {
|
||||
rsp.add(ReplicationHandler.FILE_STREAM, new SolrCore.RawWriter() {
|
||||
|
@ -181,7 +180,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
|
||||
} else {
|
||||
throw new SolrException(SolrException.ErrorCode.NOT_FOUND,
|
||||
MessageFormat.format("Invalid combination of blobName {0} and version {1}", blobName, String.valueOf(version)));
|
||||
StrUtils.formatString("Invalid combination of blobName {0} and version {1}", blobName, version));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -196,7 +195,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
|
||||
req.forward(null,
|
||||
new MapSolrParams((Map) makeMap(
|
||||
"q", MessageFormat.format(q, blobName, version),
|
||||
"q", StrUtils.formatString(q, blobName, version),
|
||||
"fl", "id,size,version,timestamp,blobName,md5",
|
||||
"sort", "version desc"))
|
||||
, rsp);
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.apache.solr.util.CommandOperation;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.text.MessageFormat.format;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.apache.solr.common.params.CoreAdminParams.NAME;
|
||||
import static org.apache.solr.core.ConfigOverlay.NOT_EDITABLE;
|
||||
|
@ -253,7 +252,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
if (op.hasError()) break;
|
||||
for (String s : name) {
|
||||
if (params.getParams(s) == null) {
|
||||
op.addError(MessageFormat.format("can't delete . No such params ''{0}'' exist", s));
|
||||
op.addError(StrUtils.formatString("can't delete . No such params ''{0}'' exist", s));
|
||||
}
|
||||
params = params.setParams(s, null);
|
||||
}
|
||||
|
@ -303,7 +302,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
default: {
|
||||
List<String> pcs = StrUtils.splitSmart(op.name.toLowerCase(Locale.ROOT), '-');
|
||||
if (pcs.size() != 2) {
|
||||
op.addError(MessageFormat.format("Unknown operation ''{0}'' ", op.name));
|
||||
op.addError(StrUtils.formatString("Unknown operation ''{0}'' ", op.name));
|
||||
} else {
|
||||
String prefix = pcs.get(0);
|
||||
String name = pcs.get(1);
|
||||
|
@ -315,7 +314,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
overlay = updateNamedPlugin(info, op, overlay, prefix.equals("create") || prefix.equals("add"));
|
||||
}
|
||||
} else {
|
||||
op.addError(MessageFormat.format("Unknown operation ''{0}'' ", op.name));
|
||||
op.addError(StrUtils.formatString("Unknown operation ''{0}'' ", op.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +347,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
if (overlay.getNamedPlugins(typ).containsKey(name)) {
|
||||
return overlay.deleteNamedPlugin(name, typ);
|
||||
} else {
|
||||
op.addError(MessageFormat.format("NO such {0} ''{1}'' ", typ, name));
|
||||
op.addError(StrUtils.formatString("NO such {0} ''{1}'' ", typ, name));
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +362,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
if (!verifyClass(op, clz, info.clazz)) return overlay;
|
||||
if (overlay.getNamedPlugins(info.tag).containsKey(name)) {
|
||||
if (isCeate) {
|
||||
op.addError(MessageFormat.format(" ''{0}'' already exists . Do an ''{1}'' , if you want to change it ", name, "update-" + info.tag.toLowerCase(Locale.ROOT)));
|
||||
op.addError(StrUtils.formatString(" ''{0}'' already exists . Do an ''{1}'' , if you want to change it ", name, "update-" + info.tag.toLowerCase(Locale.ROOT)));
|
||||
return overlay;
|
||||
} else {
|
||||
return overlay.addNamedPlugin(op.getDataMap(), info.tag);
|
||||
|
@ -372,7 +371,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
if (isCeate) {
|
||||
return overlay.addNamedPlugin(op.getDataMap(), info.tag);
|
||||
} else {
|
||||
op.addError(MessageFormat.format(" ''{0}'' does not exist . Do an ''{1}'' , if you want to create it ", name, "create-" + info.tag.toLowerCase(Locale.ROOT)));
|
||||
op.addError(StrUtils.formatString(" ''{0}'' does not exist . Do an ''{1}'' , if you want to create it ", name, "create-" + info.tag.toLowerCase(Locale.ROOT)));
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +408,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
if (op.hasError()) return overlay;
|
||||
for (String o : name) {
|
||||
if (!overlay.getUserProps().containsKey(o)) {
|
||||
op.addError(format("No such property ''{0}''", name));
|
||||
op.addError(StrUtils.formatString("No such property ''{0}''", name));
|
||||
} else {
|
||||
overlay = overlay.unsetUserProperty(o);
|
||||
}
|
||||
|
@ -424,7 +423,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
|
||||
for (String o : name) {
|
||||
if (!ConfigOverlay.isEditableProp(o, false, null)) {
|
||||
op.addError(format(NOT_EDITABLE, name));
|
||||
op.addError(StrUtils.formatString(NOT_EDITABLE, name));
|
||||
} else {
|
||||
overlay = overlay.unsetProperty(o);
|
||||
}
|
||||
|
@ -439,7 +438,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
String name = e.getKey();
|
||||
Object val = e.getValue();
|
||||
if (!ConfigOverlay.isEditableProp(name, false, null)) {
|
||||
op.addError(format(NOT_EDITABLE, name));
|
||||
op.addError(StrUtils.formatString(NOT_EDITABLE, name));
|
||||
continue;
|
||||
}
|
||||
overlay = overlay.setProperty(name, val);
|
||||
|
@ -460,7 +459,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
c == '.'
|
||||
) continue;
|
||||
else {
|
||||
return MessageFormat.format("''{0}'' name should only have chars [a-zA-Z_-.0-9] ", s);
|
||||
return StrUtils.formatString("''{0}'' name should only have chars [a-zA-Z_-.0-9] ", s);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.noggit.JSONParser;
|
||||
import org.noggit.ObjectBuilder;
|
||||
|
||||
|
@ -61,13 +62,13 @@ public class CommandOperation {
|
|||
//noinspection unchecked
|
||||
return (Map<String,Object>)commandData;
|
||||
}
|
||||
addError(MessageFormat.format("The command ''{0}'' should have the values as a json object {key:val} format", name));
|
||||
addError(StrUtils.formatString("The command ''{0}'' should have the values as a json object {key:val} format", name));
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
private Object getRootPrimitive() {
|
||||
if (commandData instanceof Map) {
|
||||
errors.add(MessageFormat.format("The value has to be a string for command : ''{0}'' ", name));
|
||||
errors.add(StrUtils.formatString("The value has to be a string for command : ''{0}'' ", name));
|
||||
return null;
|
||||
}
|
||||
return commandData;
|
||||
|
@ -92,7 +93,7 @@ public class CommandOperation {
|
|||
public List<String> getStrs(String key) {
|
||||
List<String> val = getStrs(key, null);
|
||||
if (val == null) {
|
||||
errors.add(MessageFormat.format(REQD, key));
|
||||
errors.add(StrUtils.formatString(REQD, key));
|
||||
}
|
||||
return val;
|
||||
|
||||
|
@ -136,13 +137,13 @@ public class CommandOperation {
|
|||
if (ROOT_OBJ.equals(key)) {
|
||||
Object obj = getRootPrimitive();
|
||||
if (obj == null) {
|
||||
errors.add(MessageFormat.format(REQD, name));
|
||||
errors.add(StrUtils.formatString(REQD, name));
|
||||
}
|
||||
return obj == null ? null : String.valueOf(obj);
|
||||
}
|
||||
|
||||
String s = getStr(key, null);
|
||||
if (s == null) errors.add(MessageFormat.format(REQD, key));
|
||||
if (s == null) errors.add(StrUtils.formatString(REQD, key));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -232,7 +233,7 @@ public class CommandOperation {
|
|||
Object o = getMapVal(key);
|
||||
if (o == null) return def;
|
||||
if (!(o instanceof Map)) {
|
||||
addError(MessageFormat.format("''{0}'' must be a map", key));
|
||||
addError(StrUtils.formatString("''{0}'' must be a map", key));
|
||||
return def;
|
||||
} else {
|
||||
return (Map) o;
|
||||
|
|
|
@ -396,7 +396,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
|
||||
}
|
||||
|
||||
assertTrue(MessageFormat.format("Could not get expected value ''{0}'' for path ''{1}'' full output: {2}", expected, StrUtils.join(jsonPath, '/'), getAsString(m)), success);
|
||||
assertTrue(StrUtils.formatString("Could not get expected value ''{0}'' for path ''{1}'' full output: {2}", expected, StrUtils.join(jsonPath, '/'), getAsString(m)), success);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
|||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.ConfigOverlay;
|
||||
import org.apache.solr.update.DirectUpdateHandler2;
|
||||
import org.apache.solr.util.SimplePostTool;
|
||||
|
@ -47,7 +48,6 @@ import java.io.IOException;
|
|||
import java.io.StringReader;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -146,7 +146,7 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
|
|||
assertEquals("" + bytes.limit(), String.valueOf(map.get("size")));
|
||||
return;
|
||||
}
|
||||
fail(MessageFormat.format("Could not successfully add blob after {0} attempts. Expecting {1} items. time elapsed {2} output for url is {3}",
|
||||
fail(StrUtils.formatString("Could not successfully add blob after {0} attempts. Expecting {1} items. time elapsed {2} output for url is {3}",
|
||||
i, count, System.currentTimeMillis() - start, getAsString(map)));
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.solr.common.cloud.Slice;
|
|||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.cloud.ZkConfigManager;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.apache.solr.util.RESTfulServerProvider;
|
||||
import org.apache.solr.util.RestTestHarness;
|
||||
|
@ -136,7 +137,7 @@ public class TestConfigReload extends AbstractFullDistribZkTestBase {
|
|||
if(succeeded.size() == urls.size()) break;
|
||||
succeeded.clear();
|
||||
}
|
||||
assertEquals(MessageFormat.format("tried these servers {0} succeeded only in {1} ", urls,succeeded) , urls.size(), succeeded.size());
|
||||
assertEquals(StrUtils.formatString("tried these servers {0} succeeded only in {1} ", urls, succeeded) , urls.size(), succeeded.size());
|
||||
}
|
||||
|
||||
private Map getAsMap(String uri) throws Exception {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.solr.common.cloud.DocCollection;
|
|||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.ConfigOverlay;
|
||||
import org.apache.solr.core.RequestParams;
|
||||
import org.apache.solr.core.TestSolrConfigHandler;
|
||||
|
@ -266,7 +267,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
|||
}
|
||||
|
||||
public static void compareValues(Map result, Object expected, List<String> jsonPath) {
|
||||
assertTrue(MessageFormat.format("Could not get expected value {0} for path {1} full output {2}", expected, jsonPath, getAsString(result)),
|
||||
assertTrue(StrUtils.formatString("Could not get expected value {0} for path {1} full output {2}", expected, jsonPath, getAsString(result)),
|
||||
Objects.equals(expected, ConfigOverlay.getObjectByPath(result, false, jsonPath)));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.solr.common.cloud.DocCollection;
|
|||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.ConfigOverlay;
|
||||
import org.apache.solr.util.RESTfulServerProvider;
|
||||
import org.apache.solr.util.RestTestHarness;
|
||||
|
@ -183,19 +184,19 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
|
|||
Map m = (Map) respMap.get("overlay");
|
||||
if(m!= null) m = (Map) m.get("props");
|
||||
if(m == null) {
|
||||
errmessages.add(MessageFormat.format( "overlay does not exist for cache: {0} , iteration: {1} response {2} ", cacheName, i, respMap.toString()));
|
||||
errmessages.add(StrUtils.formatString("overlay does not exist for cache: {0} , iteration: {1} response {2} ", cacheName, i, respMap.toString()));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Object o = getObjectByPath(m, true, asList("query", cacheName, "size"));
|
||||
if(!val1.equals(o)) errmessages.add(MessageFormat.format("'size' property not set, expected = {0}, actual {1}", val1,o));
|
||||
if(!val1.equals(o)) errmessages.add(StrUtils.formatString("'size' property not set, expected = {0}, actual {1}", val1, o));
|
||||
|
||||
o = getObjectByPath(m, true, asList("query", cacheName, "initialSize"));
|
||||
if(!val2.equals(o)) errmessages.add(MessageFormat.format("'initialSize' property not set, expected = {0}, actual {1}", val2,o));
|
||||
if(!val2.equals(o)) errmessages.add(StrUtils.formatString("'initialSize' property not set, expected = {0}, actual {1}", val2, o));
|
||||
|
||||
o = getObjectByPath(m, true, asList("query", cacheName, "autowarmCount"));
|
||||
if(!val3.equals(o)) errmessages.add(MessageFormat.format("'autowarmCount' property not set, expected = {0}, actual {1}", val3,o));
|
||||
if(!val3.equals(o)) errmessages.add(StrUtils.formatString("'autowarmCount' property not set, expected = {0}, actual {1}", val3, o));
|
||||
if(errmessages.isEmpty()) break;
|
||||
}
|
||||
if(!errmessages.isEmpty()) {
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.solr.schema;
|
|||
*/
|
||||
|
||||
|
||||
import static java.text.MessageFormat.format;
|
||||
import static org.apache.solr.rest.schema.TestBulkSchemaAPI.getSourceCopyFields;
|
||||
import static org.apache.solr.rest.schema.TestBulkSchemaAPI.getObj;
|
||||
|
||||
|
@ -36,6 +35,7 @@ import org.apache.solr.client.solrj.SolrClient;
|
|||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.util.RESTfulServerProvider;
|
||||
import org.apache.solr.util.RestTestHarness;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -173,17 +173,17 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
while (TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutMillis) {
|
||||
errmessages.clear();
|
||||
Map m = getObj(harness, aField, "fields");
|
||||
if (m == null) errmessages.add(format("field {0} not created", aField));
|
||||
if (m == null) errmessages.add(StrUtils.formatString("field {0} not created", aField));
|
||||
|
||||
m = getObj(harness, dynamicFldName, "dynamicFields");
|
||||
if (m == null) errmessages.add(format("dynamic field {0} not created", dynamicFldName));
|
||||
if (m == null) errmessages.add(StrUtils.formatString("dynamic field {0} not created", dynamicFldName));
|
||||
|
||||
List l = getSourceCopyFields(harness, aField);
|
||||
if (!checkCopyField(l, aField, dynamicCopyFldDest))
|
||||
errmessages.add(format("CopyField source={0},dest={1} not created", aField, dynamicCopyFldDest));
|
||||
errmessages.add(StrUtils.formatString("CopyField source={0},dest={1} not created", aField, dynamicCopyFldDest));
|
||||
|
||||
m = getObj(harness, newFieldTypeName, "fieldTypes");
|
||||
if (m == null) errmessages.add(format("new type {0} not created", newFieldTypeName));
|
||||
if (m == null) errmessages.add(StrUtils.formatString("new type {0} not created", newFieldTypeName));
|
||||
|
||||
if (errmessages.isEmpty()) break;
|
||||
|
||||
|
@ -243,17 +243,17 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
while (TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutMillis) {
|
||||
errmessages.clear();
|
||||
Map m = getObj(harness, aField, "fields");
|
||||
if (m == null) errmessages.add(format("field {0} no longer present", aField));
|
||||
if (m == null) errmessages.add(StrUtils.formatString("field {0} no longer present", aField));
|
||||
|
||||
m = getObj(harness, dynamicFldName, "dynamicFields");
|
||||
if (m == null) errmessages.add(format("dynamic field {0} no longer present", dynamicFldName));
|
||||
if (m == null) errmessages.add(StrUtils.formatString("dynamic field {0} no longer present", dynamicFldName));
|
||||
|
||||
List l = getSourceCopyFields(harness, aField);
|
||||
if (!checkCopyField(l, aField, dynamicCopyFldDest))
|
||||
errmessages.add(format("CopyField source={0},dest={1} no longer present", aField, dynamicCopyFldDest));
|
||||
errmessages.add(StrUtils.formatString("CopyField source={0},dest={1} no longer present", aField, dynamicCopyFldDest));
|
||||
|
||||
m = getObj(harness, newFieldTypeName, "fieldTypes");
|
||||
if (m == null) errmessages.add(format("new type {0} no longer present", newFieldTypeName));
|
||||
if (m == null) errmessages.add(StrUtils.formatString("new type {0} no longer present", newFieldTypeName));
|
||||
|
||||
if (errmessages.isEmpty()) break;
|
||||
|
||||
|
@ -305,17 +305,17 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
while (TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutMillis) {
|
||||
errmessages.clear();
|
||||
Map m = getObj(harness, aField, "fields");
|
||||
if (m != null) errmessages.add(format("field {0} still exists", aField));
|
||||
if (m != null) errmessages.add(StrUtils.formatString("field {0} still exists", aField));
|
||||
|
||||
m = getObj(harness, dynamicFldName, "dynamicFields");
|
||||
if (m != null) errmessages.add(format("dynamic field {0} still exists", dynamicFldName));
|
||||
if (m != null) errmessages.add(StrUtils.formatString("dynamic field {0} still exists", dynamicFldName));
|
||||
|
||||
List l = getSourceCopyFields(harness, aField);
|
||||
if (checkCopyField(l, aField, dynamicCopyFldDest))
|
||||
errmessages.add(format("CopyField source={0},dest={1} still exists", aField, dynamicCopyFldDest));
|
||||
errmessages.add(StrUtils.formatString("CopyField source={0},dest={1} still exists", aField, dynamicCopyFldDest));
|
||||
|
||||
m = getObj(harness, newFieldTypeName, "fieldTypes");
|
||||
if (m != null) errmessages.add(format("new type {0} still exists", newFieldTypeName));
|
||||
if (m != null) errmessages.add(StrUtils.formatString("new type {0} still exists", newFieldTypeName));
|
||||
|
||||
if (errmessages.isEmpty()) break;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.solr.common.util;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -305,5 +306,7 @@ public class StrUtils {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static String formatString(String pattern, Object... args) {
|
||||
return new MessageFormat(pattern, Locale.ROOT).format(args);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue