This commit is contained in:
Erick Erickson 2020-07-12 22:41:08 -04:00
parent 8c9c0640cf
commit c346881ad6
26 changed files with 77 additions and 54 deletions

View File

@ -105,11 +105,18 @@ public final class FastCharStream implements CharStream {
}
}
@Override
/**
* Returns the column position of the character last read.
* @deprecated see: #getEndColumn
*/
@Deprecated
@Override
public final int getColumn() {
return bufferStart + bufferPosition;
}
/**
* @deprecated see #getEndLine
*/
@Override
@Deprecated
public final int getLine() {

View File

@ -105,13 +105,20 @@ public final class FastCharStream implements CharStream {
}
}
@Override
/**
* Returns the column position of the character last read.
* @deprecated see #getEndColumn
*/
@Deprecated
@Override
public final int getColumn() {
return bufferStart + bufferPosition;
}
@Override
/**
* @deprecated see #getEndLine
*/
@Deprecated
@Override
public final int getLine() {
return 1;
}

View File

@ -104,13 +104,20 @@ public final class FastCharStream implements CharStream {
}
}
@Override
/**
* Returns the column position of the character last read.
* @deprecated see: #getEndColumn
*/
@Deprecated
@Override
public final int getColumn() {
return bufferStart + bufferPosition;
}
@Override
/**
* @deprecated see: #getEndLine
*/
@Deprecated
@Override
public final int getLine() {
return 1;
}

View File

@ -145,6 +145,9 @@ Other Changes
* SOLR-10742: SolrCores.getNamesForCore is quite inefficient and blocks other core operations.
NOTE: this experimental method has been removed (Erick Erickson)
* SOLR-13939: Extract any non-gradle related patches (deprecations, URL fixes, etc.) from gradle effort. NOTE:
this will be in several separate commits/pushes. (Erick Erickson)
================== 8.6.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -84,9 +84,8 @@ public class ContextImpl extends Context {
}
@Override
@SuppressWarnings({"unchecked"})
public List<Map<String, String>> getAllEntityFields() {
return epw==null || epw.getEntity() == null ? Collections.EMPTY_LIST : epw.getEntity().getAllFieldsList();
return epw==null || epw.getEntity() == null ? Collections.emptyList() : epw.getEntity().getAllFieldsList();
}
@Override

View File

@ -79,12 +79,12 @@ public class EntityProcessorWrapper extends EntityProcessor {
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked"})
void loadTransformers() {
String transClasses = context.getEntityAttribute(TRANSFORMER);
if (transClasses == null) {
transformers = Collections.EMPTY_LIST;
transformers = Collections.emptyList();
return;
}

View File

@ -184,8 +184,7 @@ public class XPathEntityProcessor extends EntityProcessorBase {
}
}
String url = context.getEntityAttribute(URL);
@SuppressWarnings({"unchecked"})
List<String> l = url == null ? Collections.EMPTY_LIST : resolver.getVariables(url);
List<String> l = url == null ? Collections.emptyList() : resolver.getVariables(url);
for (String s : l) {
if (s.startsWith(entityName + ".")) {
if (placeHolderVariables == null)

View File

@ -55,7 +55,7 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
FileListEntityProcessor.FILE_NAME, "xml$",
FileListEntityProcessor.BASE_DIR, tmpdir.getAbsolutePath());
Context c = getContext(null,
new VariableResolver(), null, Context.FULL_DUMP, Collections.EMPTY_LIST, attrs);
new VariableResolver(), null, Context.FULL_DUMP, Collections.emptyList(), attrs);
FileListEntityProcessor fileListEntityProcessor = new FileListEntityProcessor();
fileListEntityProcessor.init(c);
List<String> fList = new ArrayList<>();
@ -122,10 +122,10 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
assertEquals(l, new HashSet<>(fList));
}
@SuppressWarnings("unchecked")
static List<String> getFiles(VariableResolver resolver, @SuppressWarnings({"rawtypes"})Map attrs) {
@SuppressWarnings({"unchecked"})
Context c = getContext(null,
resolver, null, Context.FULL_DUMP, Collections.EMPTY_LIST, attrs);
resolver, null, Context.FULL_DUMP, Collections.emptyList(), attrs);
FileListEntityProcessor fileListEntityProcessor = new FileListEntityProcessor();
fileListEntityProcessor.init(c);
List<String> fList = new ArrayList<>();

View File

@ -97,7 +97,7 @@ public class TestLineEntityProcessor extends AbstractDataImportHandlerTestCase {
new VariableResolver(), //resolver
getDataSource(filecontents), //parentDataSource
Context.FULL_DUMP, //currProcess
Collections.EMPTY_LIST, //entityFields
Collections.emptyList(), //entityFields
attrs //entityAttrs
);
LineEntityProcessor ep = new LineEntityProcessor();
@ -137,7 +137,7 @@ public class TestLineEntityProcessor extends AbstractDataImportHandlerTestCase {
new VariableResolver(), //resolver
getDataSource(filecontents), //parentDataSource
Context.FULL_DUMP, //currProcess
Collections.EMPTY_LIST, //entityFields
Collections.emptyList(), //entityFields
attrs //entityAttrs
);
LineEntityProcessor ep = new LineEntityProcessor();
@ -175,7 +175,7 @@ public class TestLineEntityProcessor extends AbstractDataImportHandlerTestCase {
new VariableResolver(), //resolver
getDataSource(filecontents), //parentDataSource
Context.FULL_DUMP, //currProcess
Collections.EMPTY_LIST, //entityFields
Collections.emptyList(), //entityFields
attrs //entityAttrs
);
LineEntityProcessor ep = new LineEntityProcessor();

View File

@ -19,7 +19,6 @@ package org.apache.solr.response;
import java.io.File;
import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.Writer;
@ -130,7 +129,6 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
public void inform(SolrCore core) {
// need to leverage SolrResourceLoader, so load init.properties.file here instead of init()
if (initPropertiesFileName != null) {
InputStream is = null;
try {
velocityInitProps.load(new InputStreamReader(core.getResourceLoader().openResource(initPropertiesFileName), StandardCharsets.UTF_8));
} catch (IOException e) {

View File

@ -19,10 +19,10 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Paths;
import java.util.List;
import java.util.ArrayList;
import org.apache.hadoop.fs.Path;
import org.apache.solr.cloud.overseer.OverseerAction;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@ -71,7 +71,7 @@ class ShardLeaderElectionContextBase extends ElectionContext {
this.shardId = shardId;
this.collection = collection;
String parent = new Path(leaderPath).getParent().toString();
String parent = Paths.get(leaderPath).getParent().toString();
ZkCmdExecutor zcmd = new ZkCmdExecutor(30000);
// only if /collections/{collection} exists already do we succeed in creating this path
log.info("make sure parent is created {}", parent);
@ -99,7 +99,7 @@ class ShardLeaderElectionContextBase extends ElectionContext {
// version whenever a leader registers.
log.debug("Removing leader registration node on cancel: {} {}", leaderPath, leaderZkNodeParentVersion);
List<Op> ops = new ArrayList<>(2);
ops.add(Op.check(new Path(leaderPath).getParent().toString(), leaderZkNodeParentVersion));
ops.add(Op.check(Paths.get(leaderPath).getParent().toString(), leaderZkNodeParentVersion));
ops.add(Op.delete(leaderPath, -1));
zkClient.multi(ops, true);
} catch (InterruptedException e) {
@ -119,7 +119,7 @@ class ShardLeaderElectionContextBase extends ElectionContext {
throws KeeperException, InterruptedException, IOException {
// register as leader - if an ephemeral is already there, wait to see if it goes away
String parent = new Path(leaderPath).getParent().toString();
String parent = Paths.get(leaderPath).getParent().toString();
try {
RetryUtil.retryOnThrowable(NodeExistsException.class, 60000, 5000, () -> {
synchronized (lock) {

View File

@ -1489,7 +1489,7 @@ public class IndexFetcher {
@SuppressWarnings({"unchecked"})
private Collection<Map<String, Object>> getModifiedConfFiles(List<Map<String, Object>> confFilesToDownload) {
if (confFilesToDownload == null || confFilesToDownload.isEmpty())
return Collections.EMPTY_LIST;
return Collections.emptyList();
//build a map with alias/name as the key
@SuppressWarnings({"rawtypes"})
Map<String, Map<String, Object>> nameVsFile = new HashMap<>();
@ -1512,7 +1512,7 @@ public class IndexFetcher {
nameVsFile.remove(name); //checksums are same so the file need not be downloaded
}
}
return nameVsFile.isEmpty() ? Collections.EMPTY_LIST : nameVsFile.values();
return nameVsFile.isEmpty() ? Collections.emptyList() : nameVsFile.values();
}
/**
@ -1570,49 +1570,43 @@ public class IndexFetcher {
return timeElapsed;
}
@SuppressWarnings({"unchecked"})
List<Map<String, Object>> getTlogFilesToDownload() {
//make a copy first because it can be null later
List<Map<String, Object>> tmp = tlogFilesToDownload;
//create a new instance. or else iterator may fail
return tmp == null ? Collections.EMPTY_LIST : new ArrayList<>(tmp);
return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
}
@SuppressWarnings({"unchecked"})
List<Map<String, Object>> getTlogFilesDownloaded() {
//make a copy first because it can be null later
List<Map<String, Object>> tmp = tlogFilesDownloaded;
// NOTE: it's safe to make a copy of a SynchronizedCollection(ArrayList)
return tmp == null ? Collections.EMPTY_LIST : new ArrayList<>(tmp);
return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
}
@SuppressWarnings({"unchecked"})
List<Map<String, Object>> getConfFilesToDownload() {
//make a copy first because it can be null later
List<Map<String, Object>> tmp = confFilesToDownload;
//create a new instance. or else iterator may fail
return tmp == null ? Collections.EMPTY_LIST : new ArrayList<>(tmp);
return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
}
@SuppressWarnings({"unchecked"})
List<Map<String, Object>> getConfFilesDownloaded() {
//make a copy first because it can be null later
List<Map<String, Object>> tmp = confFilesDownloaded;
// NOTE: it's safe to make a copy of a SynchronizedCollection(ArrayList)
return tmp == null ? Collections.EMPTY_LIST : new ArrayList<>(tmp);
return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
}
@SuppressWarnings({"unchecked"})
List<Map<String, Object>> getFilesToDownload() {
//make a copy first because it can be null later
List<Map<String, Object>> tmp = filesToDownload;
return tmp == null ? Collections.EMPTY_LIST : new ArrayList<>(tmp);
return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
}
@SuppressWarnings({"unchecked"})
List<Map<String, Object>> getFilesDownloaded() {
List<Map<String, Object>> tmp = filesDownloaded;
return tmp == null ? Collections.EMPTY_LIST : new ArrayList<>(tmp);
return tmp == null ? Collections.emptyList() : new ArrayList<>(tmp);
}
// TODO: currently does not reflect conf files

View File

@ -619,7 +619,6 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
rsp.add(STATUS, OK_STATUS);
}
@SuppressWarnings("unchecked")
private void getFileList(SolrParams solrParams, SolrQueryResponse rsp) {
final IndexDeletionPolicyWrapper delPol = core.getDeletionPolicy();
final long gen = Long.parseLong(solrParams.required().get(GENERATION));
@ -629,7 +628,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
if (gen == -1) {
commit = delPol.getAndSaveLatestCommit();
if (null == commit) {
rsp.add(CMD_GET_FILE_LIST, Collections.EMPTY_LIST);
rsp.add(CMD_GET_FILE_LIST, Collections.emptyList());
return;
}
} else {

View File

@ -110,10 +110,22 @@ public final class FastCharStream implements CharStream {
}
}
@Override
@Deprecated
/**
* Returns the column position of the character last read.
* @deprecated
* @see #getEndColumn
*/
public final int getLine() {
return 1;
}
@Override
@Deprecated
/**
* Returns the column position of the character last read.
* @deprecated
* @see #getEndColumn
*/
public final int getColumn() {
return bufferStart + bufferPosition;
}

View File

@ -924,7 +924,7 @@ abstract class FacetFieldProcessor extends FacetProcessor<FacetField> {
@SuppressWarnings({"unchecked"})
static <T> List<T> asList(Object list) {
return list != null ? (List<T>)list : Collections.EMPTY_LIST;
return list != null ? (List<T>)list : Collections.emptyList();
}
@SuppressWarnings({"rawtypes", "unchecked"})

View File

@ -210,9 +210,8 @@ public class GeoDistValueSourceParser extends ValueSourceParser {
final SpatialStrategy strategy;
final DistanceUnits distanceUnits;
@SuppressWarnings({"unchecked"})
public SpatialStrategyMultiValueSource(SpatialStrategy strategy, DistanceUnits distanceUnits) {
super(Collections.EMPTY_LIST);
super(Collections.emptyList());
this.strategy = strategy;
this.distanceUnits = distanceUnits;
}

View File

@ -1205,11 +1205,10 @@ public class HttpSolrCall {
static final String CONTENT_LENGTH_HEADER = "Content-Length";
List<CommandOperation> parsedCommands;
@SuppressWarnings({"unchecked"})
public List<CommandOperation> getCommands(boolean validateInput) {
if (parsedCommands == null) {
Iterable<ContentStream> contentStreams = solrReq.getContentStreams();
if (contentStreams == null) parsedCommands = Collections.EMPTY_LIST;
if (contentStreams == null) parsedCommands = Collections.emptyList();
else {
parsedCommands = ApiBag.getCommandOperations(contentStreams.iterator().next(), getValidators(), validateInput);
}

View File

@ -196,7 +196,7 @@ public class TestReplicationHandlerDiskOverFlow extends SolrTestCaseJ4 {
"OK", response._getStr("status", null));
assertEquals("threads encountered failures (see logs for when)",
Collections.EMPTY_LIST, threadFailures);
Collections.emptyList(), threadFailures);
response = slaveClient.query(new SolrQuery().setQuery("*:*").setRows(0));
assertEquals("docs in slave", docsInMaster, response.getResults().getNumFound());

View File

@ -121,7 +121,7 @@ public class MetricsHistoryHandlerTest extends SolrCloudTestCase {
@Test
//Commented 14-Oct-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 15-Sep-2018
public void testBasic() throws Exception {
timeSource.sleep(10000);
timeSource.sleep(15000);
List<Pair<String, Long>> list = handler.getFactory().list(100);
// solr.jvm, solr.node, solr.collection..system
assertEquals(list.toString(), 3, list.size());

View File

@ -268,8 +268,7 @@ public class PolicyHelper {
ctx.max = max;
ctx.session = policy.createSession(cloudManager);
String[] t = params == null ? null : params.getParams("type");
@SuppressWarnings({"unchecked"})
List<String> types = t == null? Collections.EMPTY_LIST: Arrays.asList(t);
List<String> types = t == null? Collections.emptyList(): Arrays.asList(t);
if(types.isEmpty() || types.contains(violation.name())) {
List<Violation> violations = ctx.session.getViolations();

View File

@ -342,7 +342,7 @@ public class JavaBinUpdateRequestCodec {
handler.update(sdoc, updateRequest, commitWithin, overwrite);
}
return Collections.EMPTY_LIST;
return Collections.emptyList();
} finally {
super.readStringAsCharSeq = false;

View File

@ -407,6 +407,8 @@ public class SolrDocument extends SolrDocumentBase<Object, SolrDocument> impleme
}
@Override
@Deprecated
public int getChildDocumentCount() {
if (_childDocuments == null) return 0;
return _childDocuments.size();

View File

@ -289,6 +289,7 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
}
@Override
@Deprecated
public int getChildDocumentCount() {
return hasChildDocuments() ? _childDocuments.size(): 0;
}

View File

@ -188,13 +188,12 @@ public class CompositeIdRouter extends HashBasedRouter {
}
@Override
@SuppressWarnings({"unchecked"})
public List<Range> partitionRange(int partitions, Range range) {
int min = range.min;
int max = range.max;
assert max >= min;
if (partitions == 0) return Collections.EMPTY_LIST;
if (partitions == 0) return Collections.emptyList();
long rangeSize = (long) max - (long) min;
long rangeStep = Math.max(1, rangeSize / partitions);

View File

@ -170,7 +170,6 @@ public abstract class DocRouter {
* of variation in resulting ranges - odd ranges will be larger and even ranges will be smaller
* by up to that percentage.
*/
@SuppressWarnings({"unchecked"})
public List<Range> partitionRange(int partitions, Range range, float fuzz) {
int min = range.min;
int max = range.max;
@ -181,7 +180,7 @@ public abstract class DocRouter {
} else if (fuzz < 0.0f) {
fuzz = 0.0f;
}
if (partitions == 0) return Collections.EMPTY_LIST;
if (partitions == 0) return Collections.emptyList();
long rangeSize = (long)max - (long)min;
long rangeStep = Math.max(1, rangeSize / partitions);
long fuzzStep = Math.round(rangeStep * (double)fuzz / 2.0);

View File

@ -94,7 +94,7 @@ public class SolrDocumentTest extends SolrTestCase
try { doc.getFieldValuesMap().putAll( null ); fail( "should be unsupported!" ); } catch( UnsupportedOperationException ex ){}
try { doc.getFieldValuesMap().values(); fail( "should be unsupported!" ); } catch( UnsupportedOperationException ex ){}
try { doc.getFieldValuesMap().remove( "key" ); fail( "should be unsupported!" ); } catch( UnsupportedOperationException ex ){}
try { doc.getFieldValueMap().put( "key", Collections.EMPTY_LIST ); fail( "should be unsupported!" ); } catch( UnsupportedOperationException ex ){}
try { doc.getFieldValueMap().put( "key", Collections.emptyList() ); fail( "should be unsupported!" ); } catch( UnsupportedOperationException ex ){}
assertEquals( null, doc.getFieldValueMap().get( "aaa" ) );
doc.setField( "aaa", "bbb" );