SOLR-14526: fix or suppress warnings in apache/solr/core

This commit is contained in:
Erick Erickson 2020-06-02 09:08:11 -04:00
parent f59f8fd77b
commit db9cd0cebb
34 changed files with 156 additions and 36 deletions

View File

@ -269,6 +269,9 @@ Other Changes
* SOLR-14474: Fix remaining auxilliary class warnings in Solr (Erick Erickson) * SOLR-14474: Fix remaining auxilliary class warnings in Solr (Erick Erickson)
* SOLR-14519: Fix or suppress warnings in solr/cloud/autoscaling/ (Erick Erickson) * SOLR-14519: Fix or suppress warnings in solr/cloud/autoscaling/ (Erick Erickson)
* SOLR-14526: fix or suppress warnings in apache/solr/core (Erick Erickson)
================== 8.5.2 ================== ================== 8.5.2 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -29,11 +29,13 @@ public class AbstractSolrEventListener implements SolrEventListener {
public AbstractSolrEventListener(SolrCore core) { public AbstractSolrEventListener(SolrCore core) {
this.core = core; this.core = core;
} }
@SuppressWarnings({"rawtypes"})
private NamedList args; private NamedList args;
@SuppressWarnings({"rawtypes"})
public NamedList getArgs() { return args; } public NamedList getArgs() { return args; }
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
this.args = args.clone(); this.args = args.clone();
} }
@ -67,6 +69,7 @@ public class AbstractSolrEventListener implements SolrEventListener {
* @param currentSearcher If null, add FIRST_SEARCHER, otherwise NEW_SEARCHER * @param currentSearcher If null, add FIRST_SEARCHER, otherwise NEW_SEARCHER
* @param nlst The named list to add the EVENT value to * @param nlst The named list to add the EVENT value to
*/ */
@SuppressWarnings({"unchecked", "rawtypes"})
protected NamedList addEventParms(SolrIndexSearcher currentSearcher, NamedList nlst) { protected NamedList addEventParms(SolrIndexSearcher currentSearcher, NamedList nlst) {
NamedList result = new NamedList(); NamedList result = new NamedList();
result.addAll(nlst); result.addAll(nlst);

View File

@ -79,9 +79,11 @@ public class BlobRepository {
} }
private final CoreContainer coreContainer; private final CoreContainer coreContainer;
@SuppressWarnings({"rawtypes"})
private Map<String, BlobContent> blobs = createMap(); private Map<String, BlobContent> blobs = createMap();
// for unit tests to override // for unit tests to override
@SuppressWarnings({"rawtypes"})
ConcurrentHashMap<String, BlobContent> createMap() { ConcurrentHashMap<String, BlobContent> createMap() {
return new ConcurrentHashMap<>(); return new ConcurrentHashMap<>();
} }
@ -118,8 +120,9 @@ public class BlobRepository {
return getBlobIncRef(key.concat(decoder.getName()), () -> addBlob(key, decoder)); return getBlobIncRef(key.concat(decoder.getName()), () -> addBlob(key, decoder));
} }
@SuppressWarnings({"unchecked", "rawtypes"})
BlobContentRef getBlobIncRef(String key, Decoder decoder, String url, String sha512) { BlobContentRef getBlobIncRef(String key, Decoder decoder, String url, String sha512) {
StringBuffer keyBuilder = new StringBuffer(key); StringBuilder keyBuilder = new StringBuilder(key);
if (decoder != null) keyBuilder.append(decoder.getName()); if (decoder != null) keyBuilder.append(decoder.getName());
keyBuilder.append("/").append(sha512); keyBuilder.append("/").append(sha512);
@ -127,6 +130,7 @@ public class BlobRepository {
} }
// do the actual work returning the appropriate type... // do the actual work returning the appropriate type...
@SuppressWarnings({"unchecked"})
private <T> BlobContentRef<T> getBlobIncRef(String key, Callable<BlobContent<T>> blobCreator) { private <T> BlobContentRef<T> getBlobIncRef(String key, Callable<BlobContent<T>> blobCreator) {
BlobContent<T> aBlob; BlobContent<T> aBlob;
if (this.coreContainer.isZooKeeperAware()) { if (this.coreContainer.isZooKeeperAware()) {
@ -273,7 +277,7 @@ public class BlobRepository {
* *
* @param ref The reference that is already there. Doing multiple calls with same ref will not matter * @param ref The reference that is already there. Doing multiple calls with same ref will not matter
*/ */
public void decrementBlobRefCount(BlobContentRef ref) { public void decrementBlobRefCount(@SuppressWarnings({"rawtypes"})BlobContentRef ref) {
if (ref == null) return; if (ref == null) return;
synchronized (ref.blob.references) { synchronized (ref.blob.references) {
if (!ref.blob.references.remove(ref)) { if (!ref.blob.references.remove(ref)) {
@ -285,6 +289,7 @@ public class BlobRepository {
} }
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public static class BlobContent<T> { public static class BlobContent<T> {
public final String key; public final String key;
private final T content; // holds byte buffer or cached object, holding both is a waste of memory private final T content; // holds byte buffer or cached object, holding both is a waste of memory

View File

@ -397,7 +397,7 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
} }
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings("rawtypes") NamedList args) {
maxWriteMBPerSecFlush = (Double) args.get("maxWriteMBPerSecFlush"); maxWriteMBPerSecFlush = (Double) args.get("maxWriteMBPerSecFlush");
maxWriteMBPerSecMerge = (Double) args.get("maxWriteMBPerSecMerge"); maxWriteMBPerSecMerge = (Double) args.get("maxWriteMBPerSecMerge");
maxWriteMBPerSecRead = (Double) args.get("maxWriteMBPerSecRead"); maxWriteMBPerSecRead = (Double) args.get("maxWriteMBPerSecRead");

View File

@ -25,7 +25,7 @@ import org.apache.solr.util.plugin.NamedListInitializedPlugin;
*/ */
public abstract class CodecFactory implements NamedListInitializedPlugin { public abstract class CodecFactory implements NamedListInitializedPlugin {
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
} }
public abstract Codec getCodec(); public abstract Codec getCodec();

View File

@ -41,6 +41,7 @@ public class ConfigOverlay implements MapSerializable {
private Map<String, Object> props; private Map<String, Object> props;
private Map<String, Object> userProps; private Map<String, Object> userProps;
@SuppressWarnings({"unchecked"})
public ConfigOverlay(Map<String, Object> jsonObj, int znodeVersion) { public ConfigOverlay(Map<String, Object> jsonObj, int znodeVersion) {
if (jsonObj == null) jsonObj = Collections.EMPTY_MAP; if (jsonObj == null) jsonObj = Collections.EMPTY_MAP;
this.znodeVersion = znodeVersion; this.znodeVersion = znodeVersion;
@ -61,7 +62,9 @@ public class ConfigOverlay implements MapSerializable {
return Utils.getObjectByPath(props, onlyPrimitive, hierarchy); return Utils.getObjectByPath(props, onlyPrimitive, hierarchy);
} }
@SuppressWarnings({"unchecked"})
public ConfigOverlay setUserProperty(String key, Object val) { public ConfigOverlay setUserProperty(String key, Object val) {
@SuppressWarnings({"rawtypes"})
Map copy = new LinkedHashMap(userProps); Map copy = new LinkedHashMap(userProps);
copy.put(key, val); copy.put(key, val);
Map<String, Object> jsonObj = new LinkedHashMap<>(this.data); Map<String, Object> jsonObj = new LinkedHashMap<>(this.data);
@ -71,6 +74,7 @@ public class ConfigOverlay implements MapSerializable {
public ConfigOverlay unsetUserProperty(String key) { public ConfigOverlay unsetUserProperty(String key) {
if (!userProps.containsKey(key)) return this; if (!userProps.containsKey(key)) return this;
@SuppressWarnings({"unchecked", "rawtypes"})
Map copy = new LinkedHashMap(userProps); Map copy = new LinkedHashMap(userProps);
copy.remove(key); copy.remove(key);
Map<String, Object> jsonObj = new LinkedHashMap<>(this.data); Map<String, Object> jsonObj = new LinkedHashMap<>(this.data);
@ -78,6 +82,7 @@ public class ConfigOverlay implements MapSerializable {
return new ConfigOverlay(jsonObj, znodeVersion); return new ConfigOverlay(jsonObj, znodeVersion);
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public ConfigOverlay setProperty(String name, Object val) { public ConfigOverlay setProperty(String name, Object val) {
List<String> hierarchy = checkEditable(name, false, true); List<String> hierarchy = checkEditable(name, false, true);
Map deepCopy = (Map) Utils.fromJSON(Utils.toJSON(props)); Map deepCopy = (Map) Utils.fromJSON(Utils.toJSON(props));
@ -114,6 +119,7 @@ public class ConfigOverlay implements MapSerializable {
} }
@SuppressWarnings({"rawtypes"})
public ConfigOverlay unsetProperty(String name) { public ConfigOverlay unsetProperty(String name) {
List<String> hierarchy = checkEditable(name, false, true); List<String> hierarchy = checkEditable(name, false, true);
Map deepCopy = (Map) Utils.fromJSON(Utils.toJSON(props)); Map deepCopy = (Map) Utils.fromJSON(Utils.toJSON(props));
@ -164,6 +170,7 @@ public class ConfigOverlay implements MapSerializable {
//The path maps to the xml xpath and value of 1 means it is a tag with a string value and value //The path maps to the xml xpath and value of 1 means it is a tag with a string value and value
// of 0 means it is an attribute with string value // of 0 means it is an attribute with string value
@SuppressWarnings({"rawtypes"})
private static Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json"); private static Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json");
public static boolean isEditableProp(String path, boolean isXpath, List<String> hierarchy) { public static boolean isEditableProp(String path, boolean isXpath, List<String> hierarchy) {
@ -171,6 +178,7 @@ public class ConfigOverlay implements MapSerializable {
} }
@SuppressWarnings({"rawtypes"})
public static Class checkEditable(String path, boolean isXpath, List<String> hierarchy) { public static Class checkEditable(String path, boolean isXpath, List<String> hierarchy) {
List<String> parts = StrUtils.splitSmart(path, isXpath ? '/' : '.'); List<String> parts = StrUtils.splitSmart(path, isXpath ? '/' : '.');
Object obj = editable_prop_map; Object obj = editable_prop_map;
@ -195,8 +203,10 @@ public class ConfigOverlay implements MapSerializable {
return null; return null;
} }
@SuppressWarnings({"rawtypes"})
static Class[] types = new Class[]{String.class, Boolean.class, Integer.class, Float.class}; static Class[] types = new Class[]{String.class, Boolean.class, Integer.class, Float.class};
@SuppressWarnings({"rawtypes"})
private static Class checkType(Object o, boolean isXpath, boolean isAttr) { private static Class checkType(Object o, boolean isXpath, boolean isAttr) {
if (o instanceof Long) { if (o instanceof Long) {
Long aLong = (Long) o; Long aLong = (Long) o;
@ -209,6 +219,7 @@ public class ConfigOverlay implements MapSerializable {
} }
} }
@SuppressWarnings({"unchecked"})
public Map<String, String> getEditableSubProperties(String xpath) { public Map<String, String> getEditableSubProperties(String xpath) {
Object o = Utils.getObjectByPath(props, false, StrUtils.splitSmart(xpath, '/')); Object o = Utils.getObjectByPath(props, false, StrUtils.splitSmart(xpath, '/'));
if (o instanceof Map) { if (o instanceof Map) {
@ -229,6 +240,7 @@ public class ConfigOverlay implements MapSerializable {
return map; return map;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Map> getNamedPlugins(String typ) { public Map<String, Map> getNamedPlugins(String typ) {
Map<String, Map> reqHandlers = (Map<String, Map>) data.get(typ); Map<String, Map> reqHandlers = (Map<String, Map>) data.get(typ);
if (reqHandlers == null) return Collections.EMPTY_MAP; if (reqHandlers == null) return Collections.EMPTY_MAP;
@ -236,6 +248,7 @@ public class ConfigOverlay implements MapSerializable {
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public ConfigOverlay addNamedPlugin(Map<String, Object> info, String typ) { public ConfigOverlay addNamedPlugin(Map<String, Object> info, String typ) {
Map dataCopy = Utils.getDeepCopy(data, 4); Map dataCopy = Utils.getDeepCopy(data, 4);
Map existing = (Map) dataCopy.get(typ); Map existing = (Map) dataCopy.get(typ);
@ -244,6 +257,7 @@ public class ConfigOverlay implements MapSerializable {
return new ConfigOverlay(dataCopy, this.znodeVersion); return new ConfigOverlay(dataCopy, this.znodeVersion);
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public ConfigOverlay deleteNamedPlugin(String name, String typ) { public ConfigOverlay deleteNamedPlugin(String name, String typ) {
Map dataCopy = Utils.getDeepCopy(data, 4); Map dataCopy = Utils.getDeepCopy(data, 4);
Map reqHandler = (Map) dataCopy.get(typ); Map reqHandler = (Map) dataCopy.get(typ);

View File

@ -32,10 +32,12 @@ public class ConfigSet {
private final IndexSchema indexSchema; private final IndexSchema indexSchema;
@SuppressWarnings({"rawtypes"})
private final NamedList properties; private final NamedList properties;
private final boolean trusted; private final boolean trusted;
@SuppressWarnings({"rawtypes"})
public ConfigSet(String name, SolrConfig solrConfig, IndexSchema indexSchema, public ConfigSet(String name, SolrConfig solrConfig, IndexSchema indexSchema,
NamedList properties, boolean trusted) { NamedList properties, boolean trusted) {
this.name = name; this.name = name;
@ -57,6 +59,7 @@ public class ConfigSet {
return indexSchema; return indexSchema;
} }
@SuppressWarnings({"rawtypes"})
public NamedList getProperties() { public NamedList getProperties() {
return properties; return properties;
} }

View File

@ -52,6 +52,7 @@ public class ConfigSetProperties {
* @param name the name of the config set properties file * @param name the name of the config set properties file
* @return the properties in a NamedList * @return the properties in a NamedList
*/ */
@SuppressWarnings({"rawtypes"})
public static NamedList readFromResourceLoader(SolrResourceLoader loader, String name) { public static NamedList readFromResourceLoader(SolrResourceLoader loader, String name) {
InputStreamReader reader; InputStreamReader reader;
try { try {
@ -72,6 +73,7 @@ public class ConfigSetProperties {
} }
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public static NamedList readFromInputStream(InputStreamReader reader) { public static NamedList readFromInputStream(InputStreamReader reader) {
try { try {
Object object = fromJSON(reader); Object object = fromJSON(reader);

View File

@ -61,6 +61,7 @@ public abstract class ConfigSetService {
* @param dcore the core's CoreDescriptor * @param dcore the core's CoreDescriptor
* @return a ConfigSet * @return a ConfigSet
*/ */
@SuppressWarnings({"rawtypes"})
public final ConfigSet loadConfigSet(CoreDescriptor dcore) { public final ConfigSet loadConfigSet(CoreDescriptor dcore) {
SolrResourceLoader coreLoader = createCoreResourceLoader(dcore); SolrResourceLoader coreLoader = createCoreResourceLoader(dcore);
@ -158,6 +159,7 @@ public abstract class ConfigSetService {
* @param loader the core's resource loader * @param loader the core's resource loader
* @return the ConfigSet properties * @return the ConfigSet properties
*/ */
@SuppressWarnings({"rawtypes"})
protected NamedList loadConfigSetProperties(CoreDescriptor cd, SolrResourceLoader loader) { protected NamedList loadConfigSetProperties(CoreDescriptor cd, SolrResourceLoader loader) {
return ConfigSetProperties.readFromResourceLoader(loader, cd.getConfigSetPropertiesName()); return ConfigSetProperties.readFromResourceLoader(loader, cd.getConfigSetPropertiesName());
} }
@ -166,6 +168,7 @@ public abstract class ConfigSetService {
* Return the ConfigSet flags or null if none. * Return the ConfigSet flags or null if none.
*/ */
// TODO should fold into configSetProps -- SOLR-14059 // TODO should fold into configSetProps -- SOLR-14059
@SuppressWarnings({"rawtypes"})
protected NamedList loadConfigSetFlags(CoreDescriptor cd, SolrResourceLoader loader) { protected NamedList loadConfigSetFlags(CoreDescriptor cd, SolrResourceLoader loader) {
return null; return null;
} }

View File

@ -189,6 +189,7 @@ public class CoreContainer {
private final OrderedExecutor replayUpdatesExecutor; private final OrderedExecutor replayUpdatesExecutor;
@SuppressWarnings({"rawtypes"})
protected volatile LogWatcher logging = null; protected volatile LogWatcher logging = null;
private volatile CloserThread backgroundCloser = null; private volatile CloserThread backgroundCloser = null;
@ -340,6 +341,7 @@ public class CoreContainer {
new SolrNamedThreadFactory("replayUpdatesExecutor"))); new SolrNamedThreadFactory("replayUpdatesExecutor")));
} }
@SuppressWarnings({"unchecked"})
private synchronized void initializeAuthorizationPlugin(Map<String, Object> authorizationConf) { private synchronized void initializeAuthorizationPlugin(Map<String, Object> authorizationConf) {
authorizationConf = Utils.getDeepCopy(authorizationConf, 4); authorizationConf = Utils.getDeepCopy(authorizationConf, 4);
int newVersion = readVersion(authorizationConf); int newVersion = readVersion(authorizationConf);
@ -374,6 +376,7 @@ public class CoreContainer {
} }
} }
@SuppressWarnings({"unchecked"})
private void initializeAuditloggerPlugin(Map<String, Object> auditConf) { private void initializeAuditloggerPlugin(Map<String, Object> auditConf) {
auditConf = Utils.getDeepCopy(auditConf, 4); auditConf = Utils.getDeepCopy(auditConf, 4);
int newVersion = readVersion(auditConf); int newVersion = readVersion(auditConf);
@ -409,6 +412,7 @@ public class CoreContainer {
} }
@SuppressWarnings({"unchecked", "rawtypes"})
private synchronized void initializeAuthenticationPlugin(Map<String, Object> authenticationConfig) { private synchronized void initializeAuthenticationPlugin(Map<String, Object> authenticationConfig) {
authenticationConfig = Utils.getDeepCopy(authenticationConfig, 4); authenticationConfig = Utils.getDeepCopy(authenticationConfig, 4);
int newVersion = readVersion(authenticationConfig); int newVersion = readVersion(authenticationConfig);
@ -506,6 +510,7 @@ public class CoreContainer {
} }
} }
@SuppressWarnings({"rawtypes"})
private static int readVersion(Map<String, Object> conf) { private static int readVersion(Map<String, Object> conf) {
if (conf == null) return -1; if (conf == null) return -1;
Map meta = (Map) conf.get(""); Map meta = (Map) conf.get("");
@ -856,6 +861,7 @@ public class CoreContainer {
} }
// MetricsHistoryHandler supports both cloud and standalone configs // MetricsHistoryHandler supports both cloud and standalone configs
@SuppressWarnings({"unchecked"})
private void createMetricsHistoryHandler() { private void createMetricsHistoryHandler() {
PluginInfo plugin = cfg.getMetricsConfig().getHistoryHandler(); PluginInfo plugin = cfg.getMetricsConfig().getHistoryHandler();
Map<String, Object> initArgs; Map<String, Object> initArgs;
@ -908,6 +914,7 @@ public class CoreContainer {
/** /**
* Make sure securityConfHandler is initialized * Make sure securityConfHandler is initialized
*/ */
@SuppressWarnings({"unchecked"})
private void reloadSecurityProperties() { private void reloadSecurityProperties() {
SecurityConfHandler.SecurityConfig securityConfig = securityConfHandler.getSecurityConfig(false); SecurityConfHandler.SecurityConfig securityConfig = securityConfHandler.getSecurityConfig(false);
initializeAuthorizationPlugin((Map<String, Object>) securityConfig.getData().get("authorization")); initializeAuthorizationPlugin((Map<String, Object>) securityConfig.getData().get("authorization"));
@ -1607,7 +1614,7 @@ public class CoreContainer {
} catch (SolrCoreState.CoreIsClosedException e) { } catch (SolrCoreState.CoreIsClosedException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
coreInitFailures.put(cd.getName(), new CoreLoadFailure(cd, (Exception) e)); coreInitFailures.put(cd.getName(), new CoreLoadFailure(cd, e));
throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to reload core [" + cd.getName() + "]", e); throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to reload core [" + cd.getName() + "]", e);
} finally { } finally {
if (!success && newCore != null && newCore.getOpenCount() > 0) { if (!success && newCore != null && newCore.getOpenCount() > 0) {
@ -1841,6 +1848,7 @@ public class CoreContainer {
// ---------------- CoreContainer request handlers -------------- // ---------------- CoreContainer request handlers --------------
@SuppressWarnings({"rawtypes"})
protected <T> T createHandler(String path, String handlerClass, Class<T> clazz) { protected <T> T createHandler(String path, String handlerClass, Class<T> clazz) {
T handler = loader.newInstance(handlerClass, clazz, null, new Class[]{CoreContainer.class}, new Object[]{this}); T handler = loader.newInstance(handlerClass, clazz, null, new Class[]{CoreContainer.class}, new Object[]{this});
if (handler instanceof SolrRequestHandler) { if (handler instanceof SolrRequestHandler) {
@ -1887,6 +1895,7 @@ public class CoreContainer {
return cfg.getManagementPath(); return cfg.getManagementPath();
} }
@SuppressWarnings({"rawtypes"})
public LogWatcher getLogging() { public LogWatcher getLogging() {
return logging; return logging;
} }

View File

@ -155,7 +155,7 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
} }
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings("rawtypes") NamedList args) {
super.init(args); super.init(args);
params = args.toSolrParams(); params = args.toSolrParams();
this.hdfsDataDir = getConfig(HDFS_HOME, null); this.hdfsDataDir = getConfig(HDFS_HOME, null);

View File

@ -323,7 +323,7 @@ public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy {
} }
@Override @Override
public Collection getFileNames() throws IOException { public Collection<String> getFileNames() throws IOException {
return delegate.getFileNames(); return delegate.getFileNames();
} }
@ -379,7 +379,7 @@ public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy {
} }
@Override @Override
public Map getUserData() throws IOException { public Map<String,String> getUserData() throws IOException {
return delegate.getUserData(); return delegate.getUserData();
} }
} }

View File

@ -35,7 +35,7 @@ public abstract class IndexReaderFactory implements NamedListInitializedPlugin {
* *
*/ */
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings("rawtypes") NamedList args) {
Object v = args.get("setTermIndexDivisor"); Object v = args.get("setTermIndexDivisor");
if (v != null) { if (v != null) {
throw new IllegalArgumentException("Illegal parameter 'setTermIndexDivisor'"); throw new IllegalArgumentException("Illegal parameter 'setTermIndexDivisor'");

View File

@ -38,8 +38,13 @@ public class InitParams {
public static final String TYPE = "initParams"; public static final String TYPE = "initParams";
public final String name; public final String name;
public final Set<String> paths; public final Set<String> paths;
public final NamedList defaults, invariants, appends; @SuppressWarnings({"rawtypes"})
private PluginInfo pluginInfo; public final NamedList defaults;
@SuppressWarnings({"rawtypes"})
public final NamedList invariants;
@SuppressWarnings({"rawtypes"})
public final NamedList appends;
final private PluginInfo pluginInfo;
private final Set<String> KNOWN_KEYS = ImmutableSet.of(DEFAULTS, INVARIANTS, APPENDS); private final Set<String> KNOWN_KEYS = ImmutableSet.of(DEFAULTS, INVARIANTS, APPENDS);
public InitParams(PluginInfo p) { public InitParams(PluginInfo p) {
@ -51,6 +56,7 @@ public class InitParams {
paths = Set.copyOf(StrUtils.splitSmart(pathStr, ',')); paths = Set.copyOf(StrUtils.splitSmart(pathStr, ','));
} }
this.paths = paths; this.paths = paths;
@SuppressWarnings({"rawtypes"})
NamedList nl = (NamedList) p.initArgs.get(DEFAULTS); NamedList nl = (NamedList) p.initArgs.get(DEFAULTS);
defaults = nl == null ? null : nl.getImmutableCopy(); defaults = nl == null ? null : nl.getImmutableCopy();
nl = (NamedList) p.initArgs.get(INVARIANTS); nl = (NamedList) p.initArgs.get(INVARIANTS);
@ -88,6 +94,7 @@ public class InitParams {
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public void apply(PluginInfo info) { public void apply(PluginInfo info) {
if (!info.isFromSolrConfig()) { if (!info.isFromSolrConfig()) {
//if this is a component implicitly defined in code it should be overridden by initPrams //if this is a component implicitly defined in code it should be overridden by initPrams
@ -110,6 +117,7 @@ public class InitParams {
} }
} }
@SuppressWarnings({"unchecked", "rawtypes"})
private static void merge(NamedList first, NamedList second, NamedList sink, String name, boolean appends) { private static void merge(NamedList first, NamedList second, NamedList sink, String name, boolean appends) {
if (first == null && second == null) return; if (first == null && second == null) return;
if (first == null) first = new NamedList(); if (first == null) first = new NamedList();

View File

@ -47,6 +47,7 @@ public class MMapDirectoryFactory extends StandardDirectoryFactory {
private int maxChunk; private int maxChunk;
@Override @Override
@SuppressWarnings({"rawtypes"})
public void init(NamedList args) { public void init(NamedList args) {
super.init(args); super.init(args);
SolrParams params = args.toSolrParams(); SolrParams params = args.toSolrParams();

View File

@ -44,6 +44,7 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour
private boolean allJarsLoaded = false; private boolean allJarsLoaded = false;
private final SolrResourceLoader parentLoader; private final SolrResourceLoader parentLoader;
private List<PluginBag.RuntimeLib> libs = new ArrayList<>(); private List<PluginBag.RuntimeLib> libs = new ArrayList<>();
@SuppressWarnings("rawtypes")
private Map<String, Class> classCache = new HashMap<>(); private Map<String, Class> classCache = new HashMap<>();
private List<String> errors = new ArrayList<>(); private List<String> errors = new ArrayList<>();
@ -97,6 +98,7 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour
} }
} }
@SuppressWarnings({"rawtypes"})
private synchronized Class<?> loadFromRuntimeLibs(String name) throws ClassNotFoundException { private synchronized Class<?> loadFromRuntimeLibs(String name) throws ClassNotFoundException {
Class result = classCache.get(name); Class result = classCache.get(name);
if(result != null) if(result != null)
@ -149,11 +151,12 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour
} }
@Override @Override
public void close() throws Exception { public void close() {
for (PluginBag.RuntimeLib lib : libs) { for (PluginBag.RuntimeLib lib : libs) {
try { try {
lib.close(); lib.close();
} catch (Exception e) { } catch (Exception e) {
log.error("Error closing lib {}", lib.getName(), e);
} }
} }
} }

View File

@ -36,6 +36,7 @@ public class NRTCachingDirectoryFactory extends StandardDirectoryFactory {
private double maxCachedMB = DEFAULT_MAX_CACHED_MB; private double maxCachedMB = DEFAULT_MAX_CACHED_MB;
@Override @Override
@SuppressWarnings({"rawtypes"})
public void init(NamedList args) { public void init(NamedList args) {
super.init(args); super.init(args);
SolrParams params = args.toSolrParams(); SolrParams params = args.toSolrParams();

View File

@ -69,6 +69,7 @@ public class PluginBag<T> implements AutoCloseable {
private final Map<String, PluginHolder<T>> registry; private final Map<String, PluginHolder<T>> registry;
private final Map<String, PluginHolder<T>> immutableRegistry; private final Map<String, PluginHolder<T>> immutableRegistry;
private String def; private String def;
@SuppressWarnings({"rawtypes"})
private final Class klass; private final Class klass;
private SolrCore core; private SolrCore core;
private final SolrConfig.SolrPluginInfo meta; private final SolrConfig.SolrPluginInfo meta;
@ -119,6 +120,7 @@ public class PluginBag<T> implements AutoCloseable {
/** /**
* Check if any of the mentioned names are missing. If yes, return the Set of missing names * Check if any of the mentioned names are missing. If yes, return the Set of missing names
*/ */
@SuppressWarnings({"unchecked"})
public Set<String> checkContains(Collection<String> names) { public Set<String> checkContains(Collection<String> names) {
if (names == null || names.isEmpty()) return Collections.EMPTY_SET; if (names == null || names.isEmpty()) return Collections.EMPTY_SET;
HashSet<String> result = new HashSet<>(); HashSet<String> result = new HashSet<>();
@ -126,6 +128,7 @@ public class PluginBag<T> implements AutoCloseable {
return result; return result;
} }
@SuppressWarnings({"unchecked"})
public PluginHolder<T> createPlugin(PluginInfo info) { public PluginHolder<T> createPlugin(PluginInfo info) {
if ("true".equals(String.valueOf(info.attributes.get("runtimeLib")))) { if ("true".equals(String.valueOf(info.attributes.get("runtimeLib")))) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -148,7 +151,7 @@ public class PluginBag<T> implements AutoCloseable {
PackagePluginHolder<T> holder = new PackagePluginHolder<>(info, core, meta); PackagePluginHolder<T> holder = new PackagePluginHolder<>(info, core, meta);
return holder; return holder;
} else { } else {
T inst = core.createInstance(info.className, (Class<T>) meta.clazz, meta.getCleanTag(), null, core.getResourceLoader(info.pkgName)); T inst = SolrCore.createInstance(info.className, (Class<T>) meta.clazz, meta.getCleanTag(), null, core.getResourceLoader(info.pkgName));
initInstance(inst, info); initInstance(inst, info);
return new PluginHolder<>(info, inst); return new PluginHolder<>(info, inst);
} }
@ -208,6 +211,7 @@ public class PluginBag<T> implements AutoCloseable {
return old == null ? null : old.get(); return old == null ? null : old.get();
} }
@SuppressWarnings({"unchecked"})
public PluginHolder<T> put(String name, PluginHolder<T> plugin) { public PluginHolder<T> put(String name, PluginHolder<T> plugin) {
Boolean registerApi = null; Boolean registerApi = null;
Boolean disableHandler = null; Boolean disableHandler = null;
@ -382,14 +386,21 @@ public class PluginBag<T> implements AutoCloseable {
} }
@Override @Override
public void close() throws Exception { public void close() {
// TODO: there may be a race here. One thread can be creating a plugin // TODO: there may be a race here. One thread can be creating a plugin
// and another thread can come along and close everything (missing the plugin // and another thread can come along and close everything (missing the plugin
// that is in the state of being created and will probably never have close() called on it). // that is in the state of being created and will probably never have close() called on it).
// can close() be called concurrently with other methods? // can close() be called concurrently with other methods?
if (isLoaded()) { if (isLoaded()) {
T myInst = get(); T myInst = get();
if (myInst != null && myInst instanceof AutoCloseable) ((AutoCloseable) myInst).close(); // N.B. instanceof returns false if myInst is null
if (myInst instanceof AutoCloseable) {
try {
((AutoCloseable) myInst).close();
} catch (Exception e) {
log.error("Error closing {}", inst , e);
}
}
} }
} }
@ -459,10 +470,11 @@ public class PluginBag<T> implements AutoCloseable {
MemClassLoader loader = (MemClassLoader) resourceLoader; MemClassLoader loader = (MemClassLoader) resourceLoader;
loader.loadJars(); loader.loadJars();
} }
@SuppressWarnings({"unchecked"})
Class<T> clazz = (Class<T>) pluginMeta.clazz; Class<T> clazz = (Class<T>) pluginMeta.clazz;
T localInst = null; T localInst = null;
try { try {
localInst = core.createInstance(pluginInfo.className, clazz, pluginMeta.getCleanTag(), null, resourceLoader); localInst = SolrCore.createInstance(pluginInfo.className, clazz, pluginMeta.getCleanTag(), null, resourceLoader);
} catch (SolrException e) { } catch (SolrException e) {
if (isRuntimeLib && !(resourceLoader instanceof MemClassLoader)) { if (isRuntimeLib && !(resourceLoader instanceof MemClassLoader)) {
throw new SolrException(SolrException.ErrorCode.getErrorCode(e.code()), throw new SolrException(SolrException.ErrorCode.getErrorCode(e.code()),
@ -489,8 +501,6 @@ public class PluginBag<T> implements AutoCloseable {
lazyInst = localInst; // only assign the volatile until after the plugin is completely ready to use lazyInst = localInst; // only assign the volatile until after the plugin is completely ready to use
return true; return true;
} }
} }
/** /**
@ -526,9 +536,7 @@ public class PluginBag<T> implements AutoCloseable {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, StrUtils.formatString(BlobRepository.INVALID_JAR_MSG, url, sha512, digest) ); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, StrUtils.formatString(BlobRepository.INVALID_JAR_MSG, url, sha512, digest) );
} }
log.info("dynamic library verified {}, sha512: {}", url, sha512); log.info("dynamic library verified {}, sha512: {}", url, sha512);
} }
} }
public RuntimeLib(SolrCore core) { public RuntimeLib(SolrCore core) {
@ -539,6 +547,7 @@ public class PluginBag<T> implements AutoCloseable {
return url; return url;
} }
@SuppressWarnings({"unchecked"})
void loadJar() { void loadJar() {
if (jarContent != null) return; if (jarContent != null) return;
synchronized (this) { synchronized (this) {
@ -601,7 +610,7 @@ public class PluginBag<T> implements AutoCloseable {
@Override @Override
public void close() throws Exception { public void close() {
if (jarContent != null) coreContainer.getBlobRepository().decrementBlobRefCount(jarContent); if (jarContent != null) coreContainer.getBlobRepository().decrementBlobRefCount(jarContent);
} }

View File

@ -42,6 +42,7 @@ import static org.apache.solr.schema.FieldType.CLASS_NAME;
*/ */
public class PluginInfo implements MapSerializable { public class PluginInfo implements MapSerializable {
public final String name, className, type, pkgName; public final String name, className, type, pkgName;
@SuppressWarnings({"rawtypes"})
public final NamedList initArgs; public final NamedList initArgs;
public final Map<String, String> attributes; public final Map<String, String> attributes;
public final List<PluginInfo> children; public final List<PluginInfo> children;
@ -49,7 +50,7 @@ public class PluginInfo implements MapSerializable {
public PluginInfo(String type, Map<String, String> attrs, NamedList initArgs, List<PluginInfo> children) { public PluginInfo(String type, Map<String, String> attrs, @SuppressWarnings({"rawtypes"})NamedList initArgs, List<PluginInfo> children) {
this.type = type; this.type = type;
this.name = attrs.get(NAME); this.name = attrs.get(NAME);
Pair<String, String> parsed = parseClassName(attrs.get(CLASS_NAME)); Pair<String, String> parsed = parseClassName(attrs.get(CLASS_NAME));
@ -92,6 +93,7 @@ public class PluginInfo implements MapSerializable {
isFromSolrConfig = true; isFromSolrConfig = true;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public PluginInfo(String type, Map<String,Object> map) { public PluginInfo(String type, Map<String,Object> map) {
LinkedHashMap m = new LinkedHashMap<>(map); LinkedHashMap m = new LinkedHashMap<>(map);
initArgs = new NamedList(); initArgs = new NamedList();
@ -163,6 +165,7 @@ public class PluginInfo implements MapSerializable {
return l.isEmpty() ? null:l.get(0); return l.isEmpty() ? null:l.get(0);
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Object> toMap(Map<String, Object> map) { public Map<String, Object> toMap(Map<String, Object> map) {
map.putAll(attributes); map.putAll(attributes);
Map m = map; Map m = map;
@ -197,6 +200,7 @@ public class PluginInfo implements MapSerializable {
for (PluginInfo child : children) if(type.equals(child.type)) result.add(child); for (PluginInfo child : children) if(type.equals(child.type)) result.add(child);
return result; return result;
} }
@SuppressWarnings({"rawtypes"})
public static final PluginInfo EMPTY_INFO = new PluginInfo("",Collections.<String,String>emptyMap(), new NamedList(),Collections.<PluginInfo>emptyList()); public static final PluginInfo EMPTY_INFO = new PluginInfo("",Collections.<String,String>emptyMap(), new NamedList(),Collections.<PluginInfo>emptyList());
private static final HashSet<String> NL_TAGS = new HashSet<> private static final HashSet<String> NL_TAGS = new HashSet<>

View File

@ -45,6 +45,7 @@ public class QuerySenderListener extends AbstractSolrEventListener {
} }
@Override @Override
@SuppressWarnings({"unchecked", "rawtypes"})
public void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher) { public void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher) {
final SolrIndexSearcher searcher = newSearcher; final SolrIndexSearcher searcher = newSearcher;
log.debug("QuerySenderListener sending requests to {}", newSearcher); log.debug("QuerySenderListener sending requests to {}", newSearcher);

View File

@ -47,10 +47,12 @@ import static org.apache.solr.common.util.Utils.getDeepCopy;
public class RequestParams implements MapSerializable { public class RequestParams implements MapSerializable {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@SuppressWarnings({"rawtypes"})
private final Map data; private final Map data;
private final Map<String, ParamSet> paramsets = new LinkedHashMap<>(); private final Map<String, ParamSet> paramsets = new LinkedHashMap<>();
private final int znodeVersion; private final int znodeVersion;
@SuppressWarnings({"rawtypes"})
public RequestParams(Map data, int znodeVersion) { public RequestParams(Map data, int znodeVersion) {
if (data == null) data = Collections.EMPTY_MAP; if (data == null) data = Collections.EMPTY_MAP;
this.data = data; this.data = data;
@ -67,6 +69,7 @@ public class RequestParams implements MapSerializable {
this.znodeVersion = znodeVersion; this.znodeVersion = znodeVersion;
} }
@SuppressWarnings({"rawtypes"})
public static ParamSet createParamSet(Map map, Long version) { public static ParamSet createParamSet(Map map, Long version) {
Map copy = getDeepCopy(map, 3); Map copy = getDeepCopy(map, 3);
Map meta = (Map) copy.remove(""); Map meta = (Map) copy.remove("");
@ -82,9 +85,13 @@ public class RequestParams implements MapSerializable {
* This converts Lists to arrays of strings. Because Solr expects * This converts Lists to arrays of strings. Because Solr expects
* params to be String[] * params to be String[]
*/ */
@SuppressWarnings({"unchecked", "rawtypes"})
private static Map getMapCopy(Map value) { private static Map getMapCopy(Map value) {
@SuppressWarnings({"rawtypes"})
Map copy = new LinkedHashMap<>(); Map copy = new LinkedHashMap<>();
for (Object o1 : value.entrySet()) { for (Object o1 : value.entrySet()) {
@SuppressWarnings({"rawtypes"})
Map.Entry entry = (Map.Entry) o1; Map.Entry entry = (Map.Entry) o1;
if ("".equals(entry.getKey())) { if ("".equals(entry.getKey())) {
copy.put(entry.getKey(), entry.getValue()); copy.put(entry.getKey(), entry.getValue());
@ -92,6 +99,7 @@ public class RequestParams implements MapSerializable {
} }
if (entry.getValue() != null) { if (entry.getValue() != null) {
if (entry.getValue() instanceof List) { if (entry.getValue() instanceof List) {
@SuppressWarnings({"rawtypes"})
List l = (List) entry.getValue(); List l = (List) entry.getValue();
String[] sarr = new String[l.size()]; String[] sarr = new String[l.size()];
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
@ -122,10 +130,12 @@ public class RequestParams implements MapSerializable {
} }
@Override @Override
@SuppressWarnings({"unchecked"})
public Map<String, Object> toMap(Map<String, Object> map) { public Map<String, Object> toMap(Map<String, Object> map) {
return getMapWithVersion(data, znodeVersion); return getMapWithVersion(data, znodeVersion);
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public static Map<String, Object> getMapWithVersion(Map<String, Object> data, int znodeVersion) { public static Map<String, Object> getMapWithVersion(Map<String, Object> data, int znodeVersion) {
Map result = new LinkedHashMap(); Map result = new LinkedHashMap();
result.put(ConfigOverlay.ZNODEVER, znodeVersion); result.put(ConfigOverlay.ZNODEVER, znodeVersion);
@ -133,6 +143,7 @@ public class RequestParams implements MapSerializable {
return result; return result;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public RequestParams setParams(String name, ParamSet paramSet) { public RequestParams setParams(String name, ParamSet paramSet) {
Map deepCopy = getDeepCopy(data, 3); Map deepCopy = getDeepCopy(data, 3);
Map p = (Map) deepCopy.get(NAME); Map p = (Map) deepCopy.get(NAME);
@ -182,6 +193,7 @@ public class RequestParams implements MapSerializable {
log.info("conf resource {} loaded . version : {} ", name, version); log.info("conf resource {} loaded . version : {} ", name, version);
} }
try { try {
@SuppressWarnings({"rawtypes"})
Map m = (Map) fromJSON (in); Map m = (Map) fromJSON (in);
return new Object[]{m, version}; return new Object[]{m, version};
} catch (Exception e) { } catch (Exception e) {
@ -206,10 +218,13 @@ public class RequestParams implements MapSerializable {
public static final String INVARIANTS = "_invariants_"; public static final String INVARIANTS = "_invariants_";
public static class ParamSet implements MapSerializable { public static class ParamSet implements MapSerializable {
@SuppressWarnings({"rawtypes"})
private final Map defaults, appends, invariants; private final Map defaults, appends, invariants;
Map<String, VersionedParams> paramsMap; Map<String, VersionedParams> paramsMap;
@SuppressWarnings({"rawtypes"})
public final Map meta; public final Map meta;
@SuppressWarnings({"rawtypes"})
ParamSet(Map defaults, Map invariants, Map appends, Map meta) { ParamSet(Map defaults, Map invariants, Map appends, Map meta) {
this.defaults = defaults; this.defaults = defaults;
this.invariants = invariants; this.invariants = invariants;
@ -227,6 +242,7 @@ public class RequestParams implements MapSerializable {
} }
@Override @Override
@SuppressWarnings({"unchecked"})
public Map<String, Object> toMap(Map<String, Object> result) { public Map<String, Object> toMap(Map<String, Object> result) {
result.putAll(defaults); result.putAll(defaults);
if (appends != null) result.put(APPENDS, appends); if (appends != null) result.put(APPENDS, appends);
@ -236,7 +252,8 @@ public class RequestParams implements MapSerializable {
} }
public ParamSet update(Map map) { @SuppressWarnings({"rawtypes"})
public ParamSet update(@SuppressWarnings({"rawtypes"})Map map) {
ParamSet p = createParamSet(map, null); ParamSet p = createParamSet(map, null);
return new ParamSet( return new ParamSet(
mergeMaps(getDeepCopy(defaults, 2), p.defaults), mergeMaps(getDeepCopy(defaults, 2), p.defaults),
@ -246,6 +263,7 @@ public class RequestParams implements MapSerializable {
); );
} }
@SuppressWarnings({"unchecked", "rawtypes"})
private static Map mergeMaps(Map m1, Map m2) { private static Map mergeMaps(Map m1, Map m2) {
if (m1 == null && m2 == null) return null; if (m1 == null && m2 == null) return null;
if (m1 == null) return m2; if (m1 == null) return m2;
@ -263,6 +281,7 @@ public class RequestParams implements MapSerializable {
/**get the raw map /**get the raw map
*/ */
@SuppressWarnings({"unchecked"})
public Map<String, Object> get() { public Map<String, Object> get() {
return defaults; return defaults;
} }
@ -271,6 +290,7 @@ public class RequestParams implements MapSerializable {
public static class VersionedParams extends MapSolrParams { public static class VersionedParams extends MapSolrParams {
final ParamSet paramSet; final ParamSet paramSet;
@SuppressWarnings({"unchecked", "rawtypes"})
public VersionedParams(Map map, ParamSet paramSet) { public VersionedParams(Map map, ParamSet paramSet) {
super(getMapCopy(map)); super(getMapCopy(map));
this.paramSet = paramSet; this.paramSet = paramSet;

View File

@ -73,6 +73,7 @@ public class SchemaCodecFactory extends CodecFactory implements SolrCoreAware {
} }
@Override @Override
@SuppressWarnings({"rawtypes"})
public void init(NamedList args) { public void init(NamedList args) {
super.init(args); super.init(args);
assert codec == null; assert codec == null;

View File

@ -25,6 +25,7 @@ public class SimpleTextCodecFactory extends CodecFactory {
private Codec codec; private Codec codec;
@Override @Override
@SuppressWarnings({"rawtypes"})
public void init(NamedList args) { public void init(NamedList args) {
super.init(args); super.init(args);
assert codec == null; assert codec == null;

View File

@ -368,11 +368,13 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
public static class SolrPluginInfo { public static class SolrPluginInfo {
@SuppressWarnings({"rawtypes"})
public final Class clazz; public final Class clazz;
public final String tag; public final String tag;
public final Set<PluginOpts> options; public final Set<PluginOpts> options;
@SuppressWarnings({"unchecked", "rawtypes"})
private SolrPluginInfo(Class clz, String tag, PluginOpts... opts) { private SolrPluginInfo(Class clz, String tag, PluginOpts... opts) {
this.clazz = clz; this.clazz = clz;
this.tag = tag; this.tag = tag;
@ -389,6 +391,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
} }
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public static ConfigOverlay getConfigOverlay(SolrResourceLoader loader) { public static ConfigOverlay getConfigOverlay(SolrResourceLoader loader) {
InputStream in = null; InputStream in = null;
InputStreamReader isr = null; InputStreamReader isr = null;
@ -672,6 +675,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
@Override @Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Object> toMap(Map<String, Object> map) { public Map<String, Object> toMap(Map<String, Object> map) {
LinkedHashMap result = new LinkedHashMap(); LinkedHashMap result = new LinkedHashMap();
result.put("indexWriter", makeMap("closeWaitsForMerges", indexWriterCloseWaitsForMerges)); result.put("indexWriter", makeMap("closeWaitsForMerges", indexWriterCloseWaitsForMerges));
@ -706,6 +710,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
* SearchComponent, QueryConverter, SolrEventListener, DirectoryFactory, * SearchComponent, QueryConverter, SolrEventListener, DirectoryFactory,
* IndexDeletionPolicy, IndexReaderFactory, {@link TransformerFactory} * IndexDeletionPolicy, IndexReaderFactory, {@link TransformerFactory}
*/ */
@SuppressWarnings({"unchecked", "rawtypes"})
public List<PluginInfo> getPluginInfos(String type) { public List<PluginInfo> getPluginInfos(String type) {
List<PluginInfo> result = pluginStore.get(type); List<PluginInfo> result = pluginStore.get(type);
SolrPluginInfo info = classVsSolrPluginInfo.get(type); SolrPluginInfo info = classVsSolrPluginInfo.get(type);
@ -856,6 +861,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
} }
@Override @Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Object> toMap(Map<String, Object> result) { public Map<String, Object> toMap(Map<String, Object> result) {
if (getZnodeVersion() > -1) result.put(ZNODEVER, getZnodeVersion()); if (getZnodeVersion() > -1) result.put(ZNODEVER, getZnodeVersion());
result.put(IndexSchema.LUCENE_MATCH_VERSION_PARAM, luceneMatchVersion); result.put(IndexSchema.LUCENE_MATCH_VERSION_PARAM, luceneMatchVersion);
@ -914,6 +920,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
return result; return result;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
private void addCacheConfig(Map queryMap, CacheConfig... cache) { private void addCacheConfig(Map queryMap, CacheConfig... cache) {
if (cache == null) return; if (cache == null) return;
for (CacheConfig config : cache) if (config != null) queryMap.put(config.getNodeName(), config); for (CacheConfig config : cache) if (config != null) queryMap.put(config.getNodeName(), config);

View File

@ -196,6 +196,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
private final SolrConfig solrConfig; private final SolrConfig solrConfig;
private final SolrResourceLoader resourceLoader; private final SolrResourceLoader resourceLoader;
private volatile IndexSchema schema; private volatile IndexSchema schema;
@SuppressWarnings({"rawtypes"})
private final NamedList configSetProperties; private final NamedList configSetProperties;
private final String dataDir; private final String dataDir;
private final String ulogDir; private final String ulogDir;
@ -354,6 +355,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
this.schema = replacementSchema; this.schema = replacementSchema;
} }
@SuppressWarnings({"rawtypes"})
public NamedList getConfigSetProperties() { public NamedList getConfigSetProperties() {
return configSetProperties; return configSetProperties;
} }
@ -2018,7 +2020,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
} }
public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, final Future[] waitSearcher) { public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, @SuppressWarnings({"rawtypes"})final Future[] waitSearcher) {
return getSearcher(forceNew, returnSearcher, waitSearcher, false); return getSearcher(forceNew, returnSearcher, waitSearcher, false);
} }
@ -2214,7 +2216,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
* @param waitSearcher if non-null, will be filled in with a {@link Future} that will return after the new searcher is registered. * @param waitSearcher if non-null, will be filled in with a {@link Future} that will return after the new searcher is registered.
* @param updateHandlerReopens if true, the UpdateHandler will be used when reopening a {@link SolrIndexSearcher}. * @param updateHandlerReopens if true, the UpdateHandler will be used when reopening a {@link SolrIndexSearcher}.
*/ */
public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, final Future[] waitSearcher, boolean updateHandlerReopens) { public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, @SuppressWarnings({"rawtypes"})final Future[] waitSearcher, boolean updateHandlerReopens) {
// it may take some time to open an index.... we may need to make // it may take some time to open an index.... we may need to make
// sure that two threads aren't trying to open one at the same time // sure that two threads aren't trying to open one at the same time
// if it isn't necessary. // if it isn't necessary.
@ -2321,6 +2323,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
final SolrIndexSearcher currSearcher = currSearcherHolder == null ? null : currSearcherHolder.get(); final SolrIndexSearcher currSearcher = currSearcherHolder == null ? null : currSearcherHolder.get();
@SuppressWarnings({"rawtypes"})
Future future = null; Future future = null;
// if the underlying searcher has not changed, no warming is needed // if the underlying searcher has not changed, no warming is needed
@ -2803,6 +2806,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
private final PluginBag<TransformerFactory> transformerFactories = new PluginBag<>(TransformerFactory.class, this); private final PluginBag<TransformerFactory> transformerFactories = new PluginBag<>(TransformerFactory.class, this);
@SuppressWarnings({"unchecked"})
<T> Map<String, T> createInstances(Map<String, Class<? extends T>> map) { <T> Map<String, T> createInstances(Map<String, Class<? extends T>> map) {
Map<String, T> result = new LinkedHashMap<>(map.size(), 1); Map<String, T> result = new LinkedHashMap<>(map.size(), 1);
for (Map.Entry<String, Class<? extends T>> e : map.entrySet()) { for (Map.Entry<String, Class<? extends T>> e : map.entrySet()) {
@ -2851,7 +2855,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
return def; return def;
} }
public void initDefaultPlugin(Object plugin, Class type) { public void initDefaultPlugin(Object plugin, @SuppressWarnings({"rawtypes"})Class type) {
if (plugin instanceof SolrMetricProducer) { if (plugin instanceof SolrMetricProducer) {
coreMetricManager.registerMetricProducer(type.getSimpleName() + ".default", (SolrMetricProducer) plugin); coreMetricManager.registerMetricProducer(type.getSimpleName() + ".default", (SolrMetricProducer) plugin);
} }
@ -3164,8 +3168,10 @@ public final class SolrCore implements SolrInfoBean, Closeable {
} }
} }
@SuppressWarnings({"rawtypes"})
private static final Map implicitPluginsInfo = (Map) Utils.fromJSONResource("ImplicitPlugins.json"); private static final Map implicitPluginsInfo = (Map) Utils.fromJSONResource("ImplicitPlugins.json");
@SuppressWarnings({"unchecked", "rawtypes"})
public List<PluginInfo> getImplicitHandlers() { public List<PluginInfo> getImplicitHandlers() {
List<PluginInfo> implicits = new ArrayList<>(); List<PluginInfo> implicits = new ArrayList<>();
Map requestHandlers = (Map) implicitPluginsInfo.get(SolrRequestHandler.TYPE); Map requestHandlers = (Map) implicitPluginsInfo.get(SolrRequestHandler.TYPE);
@ -3190,12 +3196,14 @@ public final class SolrCore implements SolrInfoBean, Closeable {
* @param decoder a decoder with which to convert the blob into a Java Object representation (first time only) * @param decoder a decoder with which to convert the blob into a Java Object representation (first time only)
* @return a reference to the blob that has already cached the decoded version. * @return a reference to the blob that has already cached the decoded version.
*/ */
@SuppressWarnings({"rawtypes"})
public BlobRepository.BlobContentRef loadDecodeAndCacheBlob(String key, BlobRepository.Decoder<Object> decoder) { public BlobRepository.BlobContentRef loadDecodeAndCacheBlob(String key, BlobRepository.Decoder<Object> decoder) {
// make sure component authors don't give us oddball keys with no version... // make sure component authors don't give us oddball keys with no version...
if (!BlobRepository.BLOB_KEY_PATTERN_CHECKER.matcher(key).matches()) { if (!BlobRepository.BLOB_KEY_PATTERN_CHECKER.matcher(key).matches()) {
throw new IllegalArgumentException("invalid key format, must end in /N where N is the version number"); throw new IllegalArgumentException("invalid key format, must end in /N where N is the version number");
} }
// define the blob // define the blob
@SuppressWarnings({"rawtypes"})
BlobRepository.BlobContentRef blobRef = coreContainer.getBlobRepository().getBlobIncRef(key, decoder); BlobRepository.BlobContentRef blobRef = coreContainer.getBlobRepository().getBlobIncRef(key, decoder);
addCloseHook(new CloseHook() { addCloseHook(new CloseHook() {
@Override @Override

View File

@ -48,7 +48,7 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements NamedList
private int maxOptimizedCommitsToKeep = 0; private int maxOptimizedCommitsToKeep = 0;
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings("rawtypes") NamedList args) {
String keepOptimizedOnlyString = (String) args.get("keepOptimizedOnly"); String keepOptimizedOnlyString = (String) args.get("keepOptimizedOnly");
String maxCommitsToKeepString = (String) args.get("maxCommitsToKeep"); String maxCommitsToKeepString = (String) args.get("maxCommitsToKeep");
String maxOptimizedCommitsToKeepString = (String) args.get("maxOptimizedCommitsToKeep"); String maxOptimizedCommitsToKeepString = (String) args.get("maxOptimizedCommitsToKeep");

View File

@ -505,13 +505,14 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
} }
} }
static final String empty[] = new String[0]; static final String[] empty = new String[0];
@Override @Override
public <T> T newInstance(String name, Class<T> expectedType) { public <T> T newInstance(String name, Class<T> expectedType) {
return newInstance(name, expectedType, empty); return newInstance(name, expectedType, empty);
} }
@SuppressWarnings({"rawtypes"})
private static final Class[] NO_CLASSES = new Class[0]; private static final Class[] NO_CLASSES = new Class[0];
private static final Object[] NO_OBJECTS = new Object[0]; private static final Object[] NO_OBJECTS = new Object[0];
@ -519,6 +520,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
return newInstance(cname, expectedType, subpackages, NO_CLASSES, NO_OBJECTS); return newInstance(cname, expectedType, subpackages, NO_CLASSES, NO_OBJECTS);
} }
@SuppressWarnings({"rawtypes"})
public <T> T newInstance(String cName, Class<T> expectedType, String[] subPackages, Class[] params, Object[] args) { public <T> T newInstance(String cName, Class<T> expectedType, String[] subPackages, Class[] params, Object[] args) {
Class<? extends T> clazz = findClass(cName, expectedType, subPackages); Class<? extends T> clazz = findClass(cName, expectedType, subPackages);
if (clazz == null) { if (clazz == null) {
@ -687,12 +689,13 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
/** /**
* Keep a list of classes that are allowed to implement each 'Aware' interface * Keep a list of classes that are allowed to implement each 'Aware' interface
*/ */
@SuppressWarnings({"rawtypes"})
private static final Map<Class, Class[]> awareCompatibility; private static final Map<Class, Class[]> awareCompatibility;
static { static {
awareCompatibility = new HashMap<>(); awareCompatibility = new HashMap<>();
awareCompatibility.put( awareCompatibility.put(
SolrCoreAware.class, new Class[]{ SolrCoreAware.class, new Class<?>[]{
// DO NOT ADD THINGS TO THIS LIST -- ESPECIALLY THINGS THAT CAN BE CREATED DYNAMICALLY // DO NOT ADD THINGS TO THIS LIST -- ESPECIALLY THINGS THAT CAN BE CREATED DYNAMICALLY
// VIA RUNTIME APIS -- UNTILL CAREFULLY CONSIDERING THE ISSUES MENTIONED IN SOLR-8311 // VIA RUNTIME APIS -- UNTILL CAREFULLY CONSIDERING THE ISSUES MENTIONED IN SOLR-8311
CodecFactory.class, CodecFactory.class,
@ -708,7 +711,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
); );
awareCompatibility.put( awareCompatibility.put(
ResourceLoaderAware.class, new Class[]{ ResourceLoaderAware.class, new Class<?>[]{
// DO NOT ADD THINGS TO THIS LIST -- ESPECIALLY THINGS THAT CAN BE CREATED DYNAMICALLY // DO NOT ADD THINGS TO THIS LIST -- ESPECIALLY THINGS THAT CAN BE CREATED DYNAMICALLY
// VIA RUNTIME APIS -- UNTILL CAREFULLY CONSIDERING THE ISSUES MENTIONED IN SOLR-8311 // VIA RUNTIME APIS -- UNTILL CAREFULLY CONSIDERING THE ISSUES MENTIONED IN SOLR-8311
CharFilterFactory.class, CharFilterFactory.class,
@ -723,6 +726,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
/** /**
* Utility function to throw an exception if the class is invalid * Utility function to throw an exception if the class is invalid
*/ */
@SuppressWarnings({"rawtypes"})
public static void assertAwareCompatibility(Class aware, Object obj) { public static void assertAwareCompatibility(Class aware, Object obj) {
Class[] valid = awareCompatibility.get(aware); Class[] valid = awareCompatibility.get(aware);
if (valid == null) { if (valid == null) {

View File

@ -54,6 +54,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
// deprecate this for 7.0? // deprecate this for 7.0?
this.cacheSize = cfg.getTransientCacheSize(); this.cacheSize = cfg.getTransientCacheSize();
} else { } else {
@SuppressWarnings({"rawtypes"})
NamedList args = cfg.getTransientCachePluginInfo().initArgs; NamedList args = cfg.getTransientCachePluginInfo().initArgs;
Object obj = args.get("transientCacheSize"); Object obj = args.get("transientCacheSize");
if (obj != null) { if (obj != null) {
@ -69,6 +70,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
// Still handle just having transientCacheSize defined in the body of solr.xml not in a transient handler clause. // Still handle just having transientCacheSize defined in the body of solr.xml not in a transient handler clause.
this.cacheSize = cfg.getTransientCacheSize(); this.cacheSize = cfg.getTransientCacheSize();
} else { } else {
@SuppressWarnings({"rawtypes"})
NamedList args = cfg.getTransientCachePluginInfo().initArgs; NamedList args = cfg.getTransientCachePluginInfo().initArgs;
Object obj = args.get("transientCacheSize"); Object obj = args.get("transientCacheSize");
if (obj != null) { if (obj != null) {
@ -105,6 +107,8 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
@Override @Override
public Collection<SolrCore> prepareForShutdown() { public Collection<SolrCore> prepareForShutdown() {
// Return a copy of the values // Return a copy of the values
@SuppressWarnings({"unchecked", "rawtypes"})
List<SolrCore> ret = new ArrayList(transientCores.values()); List<SolrCore> ret = new ArrayList(transientCores.values());
transientCores.clear(); transientCores.clear();
return ret; return ret;
@ -129,7 +133,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
} }
// Remove a core from the internal structures, presumably it // Remove a core from the internal structures, presumably it
// being closed. If the core is re-opened, it will be readded by CoreContainer. // being closed. If the core is re-opened, it will be re-added by CoreContainer.
@Override @Override
public SolrCore removeCore(String name) { public SolrCore removeCore(String name) {
return transientCores.remove(name); return transientCores.remove(name);

View File

@ -49,6 +49,7 @@ public class HdfsBackupRepository implements BackupRepository {
private Configuration hdfsConfig = null; private Configuration hdfsConfig = null;
private FileSystem fileSystem = null; private FileSystem fileSystem = null;
private Path baseHdfsPath = null; private Path baseHdfsPath = null;
@SuppressWarnings("rawtypes")
private NamedList config = null; private NamedList config = null;
protected int copyBufferSize = HdfsDirectory.DEFAULT_BUFFER_SIZE; protected int copyBufferSize = HdfsDirectory.DEFAULT_BUFFER_SIZE;

View File

@ -46,10 +46,11 @@ import com.google.common.base.Preconditions;
* interface e.g. NFS). * interface e.g. NFS).
*/ */
public class LocalFileSystemRepository implements BackupRepository { public class LocalFileSystemRepository implements BackupRepository {
@SuppressWarnings("rawtypes")
private NamedList config = null; private NamedList config = null;
@Override @Override
public void init(NamedList args) { public void init(@SuppressWarnings("rawtypes") NamedList args) {
this.config = args; this.config = args;
} }

View File

@ -169,6 +169,7 @@ public class SolrSnapshotManager {
throws InterruptedException, KeeperException { throws InterruptedException, KeeperException {
String zkPath = getSnapshotMetaDataZkPath(collectionName, Optional.of(commitName)); String zkPath = getSnapshotMetaDataZkPath(collectionName, Optional.of(commitName));
try { try {
@SuppressWarnings({"unchecked"})
Map<String, Object> data = (Map<String, Object>)Utils.fromJSON(zkClient.getData(zkPath, null, null, true)); Map<String, Object> data = (Map<String, Object>)Utils.fromJSON(zkClient.getData(zkPath, null, null, true));
return Optional.of(new CollectionSnapshotMetaData(data)); return Optional.of(new CollectionSnapshotMetaData(data));
} catch (KeeperException ex) { } catch (KeeperException ex) {
@ -281,13 +282,14 @@ public class SolrSnapshotManager {
* @param dir The index directory storing the snapshot. * @param dir The index directory storing the snapshot.
* @throws IOException in case of I/O errors. * @throws IOException in case of I/O errors.
*/ */
@SuppressWarnings({"try", "unused"})
private static void deleteSnapshotIndexFiles(SolrCore core, Directory dir, IndexDeletionPolicy delPolicy) throws IOException { private static void deleteSnapshotIndexFiles(SolrCore core, Directory dir, IndexDeletionPolicy delPolicy) throws IOException {
IndexWriterConfig conf = core.getSolrConfig().indexConfig.toIndexWriterConfig(core); IndexWriterConfig conf = core.getSolrConfig().indexConfig.toIndexWriterConfig(core);
conf.setOpenMode(OpenMode.APPEND); conf.setOpenMode(OpenMode.APPEND);
conf.setMergePolicy(NoMergePolicy.INSTANCE);//Don't want to merge any commits here! conf.setMergePolicy(NoMergePolicy.INSTANCE);//Don't want to merge any commits here!
conf.setIndexDeletionPolicy(delPolicy); conf.setIndexDeletionPolicy(delPolicy);
conf.setCodec(core.getCodec()); conf.setCodec(core.getCodec());
try (SolrIndexWriter iw = new SolrIndexWriter("SolrSnapshotCleaner", dir, conf)) { try (SolrIndexWriter iw = new SolrIndexWriter("SolrSnapshotCleaner", dir, conf)) {
// Do nothing. The only purpose of opening index writer is to invoke the Lucene IndexDeletionPolicy#onInit // Do nothing. The only purpose of opening index writer is to invoke the Lucene IndexDeletionPolicy#onInit
// method so that we can cleanup the files associated with specified index commit. // method so that we can cleanup the files associated with specified index commit.

View File

@ -426,6 +426,7 @@ public class SolrSnapshotsTool implements Closeable, CLIO {
return false; return false;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
private Collection<CollectionSnapshotMetaData> listCollectionSnapshots(String collectionName) private Collection<CollectionSnapshotMetaData> listCollectionSnapshots(String collectionName)
throws SolrServerException, IOException { throws SolrServerException, IOException {
CollectionAdminRequest.ListSnapshots listSnapshots = new CollectionAdminRequest.ListSnapshots(collectionName); CollectionAdminRequest.ListSnapshots listSnapshots = new CollectionAdminRequest.ListSnapshots(collectionName);

View File

@ -114,7 +114,7 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
@Override @Override
final public void init(NamedList args) { final public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"CoreAdminHandler should not be configured in solrconf.xml\n" + "CoreAdminHandler should not be configured in solrconf.xml\n" +
"it is a special Handler configured directly by the RequestDispatcher"); "it is a special Handler configured directly by the RequestDispatcher");

View File

@ -196,9 +196,10 @@ public abstract class SolrCoreState {
public abstract void setCdcrBootstrapFuture(Future<Boolean> cdcrBootstrapFuture); public abstract void setCdcrBootstrapFuture(Future<Boolean> cdcrBootstrapFuture);
@SuppressWarnings("rawtypes")
public abstract Callable getCdcrBootstrapCallable(); public abstract Callable getCdcrBootstrapCallable();
public abstract void setCdcrBootstrapCallable(Callable cdcrBootstrapCallable); public abstract void setCdcrBootstrapCallable(@SuppressWarnings("rawtypes") Callable cdcrBootstrapCallable);
public Throwable getTragicException() throws IOException { public Throwable getTragicException() throws IOException {
RefCounted<IndexWriter> ref = getIndexWriter(null); RefCounted<IndexWriter> ref = getIndexWriter(null);