diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 296d7b5cb75..bd74c7ca681 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -269,6 +269,9 @@ Other Changes * SOLR-14474: Fix remaining auxilliary class warnings in Solr (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 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/core/src/java/org/apache/solr/core/AbstractSolrEventListener.java b/solr/core/src/java/org/apache/solr/core/AbstractSolrEventListener.java index 83b2a93787f..9d278749601 100644 --- a/solr/core/src/java/org/apache/solr/core/AbstractSolrEventListener.java +++ b/solr/core/src/java/org/apache/solr/core/AbstractSolrEventListener.java @@ -29,11 +29,13 @@ public class AbstractSolrEventListener implements SolrEventListener { public AbstractSolrEventListener(SolrCore core) { this.core = core; } + @SuppressWarnings({"rawtypes"}) private NamedList args; + @SuppressWarnings({"rawtypes"}) public NamedList getArgs() { return args; } @Override - public void init(NamedList args) { + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { this.args = args.clone(); } @@ -67,6 +69,7 @@ public class AbstractSolrEventListener implements SolrEventListener { * @param currentSearcher If null, add FIRST_SEARCHER, otherwise NEW_SEARCHER * @param nlst The named list to add the EVENT value to */ + @SuppressWarnings({"unchecked", "rawtypes"}) protected NamedList addEventParms(SolrIndexSearcher currentSearcher, NamedList nlst) { NamedList result = new NamedList(); result.addAll(nlst); diff --git a/solr/core/src/java/org/apache/solr/core/BlobRepository.java b/solr/core/src/java/org/apache/solr/core/BlobRepository.java index a7d524f3c16..4e0d8648548 100644 --- a/solr/core/src/java/org/apache/solr/core/BlobRepository.java +++ b/solr/core/src/java/org/apache/solr/core/BlobRepository.java @@ -79,9 +79,11 @@ public class BlobRepository { } private final CoreContainer coreContainer; + @SuppressWarnings({"rawtypes"}) private Map blobs = createMap(); // for unit tests to override + @SuppressWarnings({"rawtypes"}) ConcurrentHashMap createMap() { return new ConcurrentHashMap<>(); } @@ -118,8 +120,9 @@ public class BlobRepository { return getBlobIncRef(key.concat(decoder.getName()), () -> addBlob(key, decoder)); } + @SuppressWarnings({"unchecked", "rawtypes"}) 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()); keyBuilder.append("/").append(sha512); @@ -127,6 +130,7 @@ public class BlobRepository { } // do the actual work returning the appropriate type... + @SuppressWarnings({"unchecked"}) private BlobContentRef getBlobIncRef(String key, Callable> blobCreator) { BlobContent aBlob; 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 */ - public void decrementBlobRefCount(BlobContentRef ref) { + public void decrementBlobRefCount(@SuppressWarnings({"rawtypes"})BlobContentRef ref) { if (ref == null) return; synchronized (ref.blob.references) { if (!ref.blob.references.remove(ref)) { @@ -285,6 +289,7 @@ public class BlobRepository { } } + @SuppressWarnings({"unchecked", "rawtypes"}) public static class BlobContent { public final String key; private final T content; // holds byte buffer or cached object, holding both is a waste of memory diff --git a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java index 34113253943..732b82c1f56 100644 --- a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java @@ -397,7 +397,7 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory { } @Override - public void init(NamedList args) { + public void init(@SuppressWarnings("rawtypes") NamedList args) { maxWriteMBPerSecFlush = (Double) args.get("maxWriteMBPerSecFlush"); maxWriteMBPerSecMerge = (Double) args.get("maxWriteMBPerSecMerge"); maxWriteMBPerSecRead = (Double) args.get("maxWriteMBPerSecRead"); diff --git a/solr/core/src/java/org/apache/solr/core/CodecFactory.java b/solr/core/src/java/org/apache/solr/core/CodecFactory.java index 36c67eba145..7ded16990f7 100644 --- a/solr/core/src/java/org/apache/solr/core/CodecFactory.java +++ b/solr/core/src/java/org/apache/solr/core/CodecFactory.java @@ -25,7 +25,7 @@ import org.apache.solr.util.plugin.NamedListInitializedPlugin; */ public abstract class CodecFactory implements NamedListInitializedPlugin { @Override - public void init(NamedList args) { + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { } public abstract Codec getCodec(); diff --git a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java index 967db856ccf..4726ae298ef 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java @@ -41,6 +41,7 @@ public class ConfigOverlay implements MapSerializable { private Map props; private Map userProps; + @SuppressWarnings({"unchecked"}) public ConfigOverlay(Map jsonObj, int znodeVersion) { if (jsonObj == null) jsonObj = Collections.EMPTY_MAP; this.znodeVersion = znodeVersion; @@ -61,7 +62,9 @@ public class ConfigOverlay implements MapSerializable { return Utils.getObjectByPath(props, onlyPrimitive, hierarchy); } + @SuppressWarnings({"unchecked"}) public ConfigOverlay setUserProperty(String key, Object val) { + @SuppressWarnings({"rawtypes"}) Map copy = new LinkedHashMap(userProps); copy.put(key, val); Map jsonObj = new LinkedHashMap<>(this.data); @@ -71,6 +74,7 @@ public class ConfigOverlay implements MapSerializable { public ConfigOverlay unsetUserProperty(String key) { if (!userProps.containsKey(key)) return this; + @SuppressWarnings({"unchecked", "rawtypes"}) Map copy = new LinkedHashMap(userProps); copy.remove(key); Map jsonObj = new LinkedHashMap<>(this.data); @@ -78,6 +82,7 @@ public class ConfigOverlay implements MapSerializable { return new ConfigOverlay(jsonObj, znodeVersion); } + @SuppressWarnings({"unchecked", "rawtypes"}) public ConfigOverlay setProperty(String name, Object val) { List hierarchy = checkEditable(name, false, true); Map deepCopy = (Map) Utils.fromJSON(Utils.toJSON(props)); @@ -114,6 +119,7 @@ public class ConfigOverlay implements MapSerializable { } + @SuppressWarnings({"rawtypes"}) public ConfigOverlay unsetProperty(String name) { List hierarchy = checkEditable(name, false, true); 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 // of 0 means it is an attribute with string value + @SuppressWarnings({"rawtypes"}) private static Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json"); public static boolean isEditableProp(String path, boolean isXpath, List hierarchy) { @@ -171,6 +178,7 @@ public class ConfigOverlay implements MapSerializable { } + @SuppressWarnings({"rawtypes"}) public static Class checkEditable(String path, boolean isXpath, List hierarchy) { List parts = StrUtils.splitSmart(path, isXpath ? '/' : '.'); Object obj = editable_prop_map; @@ -195,8 +203,10 @@ public class ConfigOverlay implements MapSerializable { return null; } + @SuppressWarnings({"rawtypes"}) 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) { if (o instanceof Long) { Long aLong = (Long) o; @@ -209,6 +219,7 @@ public class ConfigOverlay implements MapSerializable { } } + @SuppressWarnings({"unchecked"}) public Map getEditableSubProperties(String xpath) { Object o = Utils.getObjectByPath(props, false, StrUtils.splitSmart(xpath, '/')); if (o instanceof Map) { @@ -229,6 +240,7 @@ public class ConfigOverlay implements MapSerializable { return map; } + @SuppressWarnings({"unchecked", "rawtypes"}) public Map getNamedPlugins(String typ) { Map reqHandlers = (Map) data.get(typ); if (reqHandlers == null) return Collections.EMPTY_MAP; @@ -236,6 +248,7 @@ public class ConfigOverlay implements MapSerializable { } + @SuppressWarnings({"unchecked", "rawtypes"}) public ConfigOverlay addNamedPlugin(Map info, String typ) { Map dataCopy = Utils.getDeepCopy(data, 4); Map existing = (Map) dataCopy.get(typ); @@ -244,6 +257,7 @@ public class ConfigOverlay implements MapSerializable { return new ConfigOverlay(dataCopy, this.znodeVersion); } + @SuppressWarnings({"unchecked", "rawtypes"}) public ConfigOverlay deleteNamedPlugin(String name, String typ) { Map dataCopy = Utils.getDeepCopy(data, 4); Map reqHandler = (Map) dataCopy.get(typ); diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSet.java b/solr/core/src/java/org/apache/solr/core/ConfigSet.java index 671f81a9052..d6cb31de460 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigSet.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigSet.java @@ -32,10 +32,12 @@ public class ConfigSet { private final IndexSchema indexSchema; + @SuppressWarnings({"rawtypes"}) private final NamedList properties; private final boolean trusted; + @SuppressWarnings({"rawtypes"}) public ConfigSet(String name, SolrConfig solrConfig, IndexSchema indexSchema, NamedList properties, boolean trusted) { this.name = name; @@ -57,6 +59,7 @@ public class ConfigSet { return indexSchema; } + @SuppressWarnings({"rawtypes"}) public NamedList getProperties() { return properties; } diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetProperties.java b/solr/core/src/java/org/apache/solr/core/ConfigSetProperties.java index feaef8fac25..a8ca1ec4973 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigSetProperties.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigSetProperties.java @@ -52,6 +52,7 @@ public class ConfigSetProperties { * @param name the name of the config set properties file * @return the properties in a NamedList */ + @SuppressWarnings({"rawtypes"}) public static NamedList readFromResourceLoader(SolrResourceLoader loader, String name) { InputStreamReader reader; try { @@ -72,6 +73,7 @@ public class ConfigSetProperties { } } + @SuppressWarnings({"unchecked", "rawtypes"}) public static NamedList readFromInputStream(InputStreamReader reader) { try { Object object = fromJSON(reader); diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java index 7b5ca794ca3..84f94d5272b 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java @@ -61,6 +61,7 @@ public abstract class ConfigSetService { * @param dcore the core's CoreDescriptor * @return a ConfigSet */ + @SuppressWarnings({"rawtypes"}) public final ConfigSet loadConfigSet(CoreDescriptor dcore) { SolrResourceLoader coreLoader = createCoreResourceLoader(dcore); @@ -158,6 +159,7 @@ public abstract class ConfigSetService { * @param loader the core's resource loader * @return the ConfigSet properties */ + @SuppressWarnings({"rawtypes"}) protected NamedList loadConfigSetProperties(CoreDescriptor cd, SolrResourceLoader loader) { return ConfigSetProperties.readFromResourceLoader(loader, cd.getConfigSetPropertiesName()); } @@ -166,6 +168,7 @@ public abstract class ConfigSetService { * Return the ConfigSet flags or null if none. */ // TODO should fold into configSetProps -- SOLR-14059 + @SuppressWarnings({"rawtypes"}) protected NamedList loadConfigSetFlags(CoreDescriptor cd, SolrResourceLoader loader) { return null; } diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index b0ebe91f829..f968800a7c4 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -189,6 +189,7 @@ public class CoreContainer { private final OrderedExecutor replayUpdatesExecutor; + @SuppressWarnings({"rawtypes"}) protected volatile LogWatcher logging = null; private volatile CloserThread backgroundCloser = null; @@ -340,6 +341,7 @@ public class CoreContainer { new SolrNamedThreadFactory("replayUpdatesExecutor"))); } + @SuppressWarnings({"unchecked"}) private synchronized void initializeAuthorizationPlugin(Map authorizationConf) { authorizationConf = Utils.getDeepCopy(authorizationConf, 4); int newVersion = readVersion(authorizationConf); @@ -374,6 +376,7 @@ public class CoreContainer { } } + @SuppressWarnings({"unchecked"}) private void initializeAuditloggerPlugin(Map auditConf) { auditConf = Utils.getDeepCopy(auditConf, 4); int newVersion = readVersion(auditConf); @@ -409,6 +412,7 @@ public class CoreContainer { } + @SuppressWarnings({"unchecked", "rawtypes"}) private synchronized void initializeAuthenticationPlugin(Map authenticationConfig) { authenticationConfig = Utils.getDeepCopy(authenticationConfig, 4); int newVersion = readVersion(authenticationConfig); @@ -506,6 +510,7 @@ public class CoreContainer { } } + @SuppressWarnings({"rawtypes"}) private static int readVersion(Map conf) { if (conf == null) return -1; Map meta = (Map) conf.get(""); @@ -856,6 +861,7 @@ public class CoreContainer { } // MetricsHistoryHandler supports both cloud and standalone configs + @SuppressWarnings({"unchecked"}) private void createMetricsHistoryHandler() { PluginInfo plugin = cfg.getMetricsConfig().getHistoryHandler(); Map initArgs; @@ -908,6 +914,7 @@ public class CoreContainer { /** * Make sure securityConfHandler is initialized */ + @SuppressWarnings({"unchecked"}) private void reloadSecurityProperties() { SecurityConfHandler.SecurityConfig securityConfig = securityConfHandler.getSecurityConfig(false); initializeAuthorizationPlugin((Map) securityConfig.getData().get("authorization")); @@ -1607,7 +1614,7 @@ public class CoreContainer { } catch (SolrCoreState.CoreIsClosedException e) { throw 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); } finally { if (!success && newCore != null && newCore.getOpenCount() > 0) { @@ -1841,6 +1848,7 @@ public class CoreContainer { // ---------------- CoreContainer request handlers -------------- + @SuppressWarnings({"rawtypes"}) protected T createHandler(String path, String handlerClass, Class clazz) { T handler = loader.newInstance(handlerClass, clazz, null, new Class[]{CoreContainer.class}, new Object[]{this}); if (handler instanceof SolrRequestHandler) { @@ -1887,6 +1895,7 @@ public class CoreContainer { return cfg.getManagementPath(); } + @SuppressWarnings({"rawtypes"}) public LogWatcher getLogging() { return logging; } diff --git a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java index e73acd6250a..8782371e7e7 100644 --- a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java @@ -155,7 +155,7 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol } @Override - public void init(NamedList args) { + public void init(@SuppressWarnings("rawtypes") NamedList args) { super.init(args); params = args.toSolrParams(); this.hdfsDataDir = getConfig(HDFS_HOME, null); diff --git a/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java b/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java index 201c6364c40..9de8698af50 100644 --- a/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java +++ b/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java @@ -323,7 +323,7 @@ public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy { } @Override - public Collection getFileNames() throws IOException { + public Collection getFileNames() throws IOException { return delegate.getFileNames(); } @@ -379,7 +379,7 @@ public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy { } @Override - public Map getUserData() throws IOException { + public Map getUserData() throws IOException { return delegate.getUserData(); } } diff --git a/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java b/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java index 03e73b7c851..bf30d838c80 100644 --- a/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java +++ b/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java @@ -35,7 +35,7 @@ public abstract class IndexReaderFactory implements NamedListInitializedPlugin { * */ @Override - public void init(NamedList args) { + public void init(@SuppressWarnings("rawtypes") NamedList args) { Object v = args.get("setTermIndexDivisor"); if (v != null) { throw new IllegalArgumentException("Illegal parameter 'setTermIndexDivisor'"); diff --git a/solr/core/src/java/org/apache/solr/core/InitParams.java b/solr/core/src/java/org/apache/solr/core/InitParams.java index 8e7b874ecd6..ad31cf6fd8f 100644 --- a/solr/core/src/java/org/apache/solr/core/InitParams.java +++ b/solr/core/src/java/org/apache/solr/core/InitParams.java @@ -38,8 +38,13 @@ public class InitParams { public static final String TYPE = "initParams"; public final String name; public final Set paths; - public final NamedList defaults, invariants, appends; - private PluginInfo pluginInfo; + @SuppressWarnings({"rawtypes"}) + public final NamedList defaults; + @SuppressWarnings({"rawtypes"}) + public final NamedList invariants; + @SuppressWarnings({"rawtypes"}) + public final NamedList appends; + final private PluginInfo pluginInfo; private final Set KNOWN_KEYS = ImmutableSet.of(DEFAULTS, INVARIANTS, APPENDS); public InitParams(PluginInfo p) { @@ -51,6 +56,7 @@ public class InitParams { paths = Set.copyOf(StrUtils.splitSmart(pathStr, ',')); } this.paths = paths; + @SuppressWarnings({"rawtypes"}) NamedList nl = (NamedList) p.initArgs.get(DEFAULTS); defaults = nl == null ? null : nl.getImmutableCopy(); nl = (NamedList) p.initArgs.get(INVARIANTS); @@ -88,6 +94,7 @@ public class InitParams { } + @SuppressWarnings({"unchecked", "rawtypes"}) public void apply(PluginInfo info) { if (!info.isFromSolrConfig()) { //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) { if (first == null && second == null) return; if (first == null) first = new NamedList(); diff --git a/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java index 0c1875b259f..69def25ccdb 100644 --- a/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java @@ -47,6 +47,7 @@ public class MMapDirectoryFactory extends StandardDirectoryFactory { private int maxChunk; @Override + @SuppressWarnings({"rawtypes"}) public void init(NamedList args) { super.init(args); SolrParams params = args.toSolrParams(); diff --git a/solr/core/src/java/org/apache/solr/core/MemClassLoader.java b/solr/core/src/java/org/apache/solr/core/MemClassLoader.java index cf6bb4dd971..03e4de295df 100644 --- a/solr/core/src/java/org/apache/solr/core/MemClassLoader.java +++ b/solr/core/src/java/org/apache/solr/core/MemClassLoader.java @@ -44,6 +44,7 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour private boolean allJarsLoaded = false; private final SolrResourceLoader parentLoader; private List libs = new ArrayList<>(); + @SuppressWarnings("rawtypes") private Map classCache = new HashMap<>(); private List 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 { Class result = classCache.get(name); if(result != null) @@ -149,11 +151,12 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour } @Override - public void close() throws Exception { + public void close() { for (PluginBag.RuntimeLib lib : libs) { try { lib.close(); } catch (Exception e) { + log.error("Error closing lib {}", lib.getName(), e); } } } diff --git a/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java index 789ffdbe00d..4e1fad9637e 100644 --- a/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java @@ -36,6 +36,7 @@ public class NRTCachingDirectoryFactory extends StandardDirectoryFactory { private double maxCachedMB = DEFAULT_MAX_CACHED_MB; @Override + @SuppressWarnings({"rawtypes"}) public void init(NamedList args) { super.init(args); SolrParams params = args.toSolrParams(); diff --git a/solr/core/src/java/org/apache/solr/core/PluginBag.java b/solr/core/src/java/org/apache/solr/core/PluginBag.java index 2937dc569f6..2f82ccc1cf2 100644 --- a/solr/core/src/java/org/apache/solr/core/PluginBag.java +++ b/solr/core/src/java/org/apache/solr/core/PluginBag.java @@ -69,6 +69,7 @@ public class PluginBag implements AutoCloseable { private final Map> registry; private final Map> immutableRegistry; private String def; + @SuppressWarnings({"rawtypes"}) private final Class klass; private SolrCore core; private final SolrConfig.SolrPluginInfo meta; @@ -119,6 +120,7 @@ public class PluginBag implements AutoCloseable { /** * Check if any of the mentioned names are missing. If yes, return the Set of missing names */ + @SuppressWarnings({"unchecked"}) public Set checkContains(Collection names) { if (names == null || names.isEmpty()) return Collections.EMPTY_SET; HashSet result = new HashSet<>(); @@ -126,6 +128,7 @@ public class PluginBag implements AutoCloseable { return result; } + @SuppressWarnings({"unchecked"}) public PluginHolder createPlugin(PluginInfo info) { if ("true".equals(String.valueOf(info.attributes.get("runtimeLib")))) { if (log.isDebugEnabled()) { @@ -148,7 +151,7 @@ public class PluginBag implements AutoCloseable { PackagePluginHolder holder = new PackagePluginHolder<>(info, core, meta); return holder; } else { - T inst = core.createInstance(info.className, (Class) meta.clazz, meta.getCleanTag(), null, core.getResourceLoader(info.pkgName)); + T inst = SolrCore.createInstance(info.className, (Class) meta.clazz, meta.getCleanTag(), null, core.getResourceLoader(info.pkgName)); initInstance(inst, info); return new PluginHolder<>(info, inst); } @@ -208,6 +211,7 @@ public class PluginBag implements AutoCloseable { return old == null ? null : old.get(); } + @SuppressWarnings({"unchecked"}) public PluginHolder put(String name, PluginHolder plugin) { Boolean registerApi = null; Boolean disableHandler = null; @@ -382,14 +386,21 @@ public class PluginBag implements AutoCloseable { } @Override - public void close() throws Exception { + public void close() { // 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 // 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? if (isLoaded()) { 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 implements AutoCloseable { MemClassLoader loader = (MemClassLoader) resourceLoader; loader.loadJars(); } + @SuppressWarnings({"unchecked"}) Class clazz = (Class) pluginMeta.clazz; T localInst = null; try { - localInst = core.createInstance(pluginInfo.className, clazz, pluginMeta.getCleanTag(), null, resourceLoader); + localInst = SolrCore.createInstance(pluginInfo.className, clazz, pluginMeta.getCleanTag(), null, resourceLoader); } catch (SolrException e) { if (isRuntimeLib && !(resourceLoader instanceof MemClassLoader)) { throw new SolrException(SolrException.ErrorCode.getErrorCode(e.code()), @@ -489,8 +501,6 @@ public class PluginBag implements AutoCloseable { lazyInst = localInst; // only assign the volatile until after the plugin is completely ready to use return true; } - - } /** @@ -526,9 +536,7 @@ public class PluginBag implements AutoCloseable { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, StrUtils.formatString(BlobRepository.INVALID_JAR_MSG, url, sha512, digest) ); } log.info("dynamic library verified {}, sha512: {}", url, sha512); - } - } public RuntimeLib(SolrCore core) { @@ -539,6 +547,7 @@ public class PluginBag implements AutoCloseable { return url; } + @SuppressWarnings({"unchecked"}) void loadJar() { if (jarContent != null) return; synchronized (this) { @@ -601,7 +610,7 @@ public class PluginBag implements AutoCloseable { @Override - public void close() throws Exception { + public void close() { if (jarContent != null) coreContainer.getBlobRepository().decrementBlobRefCount(jarContent); } diff --git a/solr/core/src/java/org/apache/solr/core/PluginInfo.java b/solr/core/src/java/org/apache/solr/core/PluginInfo.java index bb290e12e81..428d72c5881 100644 --- a/solr/core/src/java/org/apache/solr/core/PluginInfo.java +++ b/solr/core/src/java/org/apache/solr/core/PluginInfo.java @@ -42,6 +42,7 @@ import static org.apache.solr.schema.FieldType.CLASS_NAME; */ public class PluginInfo implements MapSerializable { public final String name, className, type, pkgName; + @SuppressWarnings({"rawtypes"}) public final NamedList initArgs; public final Map attributes; public final List children; @@ -49,7 +50,7 @@ public class PluginInfo implements MapSerializable { - public PluginInfo(String type, Map attrs, NamedList initArgs, List children) { + public PluginInfo(String type, Map attrs, @SuppressWarnings({"rawtypes"})NamedList initArgs, List children) { this.type = type; this.name = attrs.get(NAME); Pair parsed = parseClassName(attrs.get(CLASS_NAME)); @@ -92,6 +93,7 @@ public class PluginInfo implements MapSerializable { isFromSolrConfig = true; } + @SuppressWarnings({"unchecked", "rawtypes"}) public PluginInfo(String type, Map map) { LinkedHashMap m = new LinkedHashMap<>(map); initArgs = new NamedList(); @@ -163,6 +165,7 @@ public class PluginInfo implements MapSerializable { return l.isEmpty() ? null:l.get(0); } + @SuppressWarnings({"unchecked", "rawtypes"}) public Map toMap(Map map) { map.putAll(attributes); Map m = map; @@ -197,6 +200,7 @@ public class PluginInfo implements MapSerializable { for (PluginInfo child : children) if(type.equals(child.type)) result.add(child); return result; } + @SuppressWarnings({"rawtypes"}) public static final PluginInfo EMPTY_INFO = new PluginInfo("",Collections.emptyMap(), new NamedList(),Collections.emptyList()); private static final HashSet NL_TAGS = new HashSet<> diff --git a/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java b/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java index d4bb6c0b210..9b751424d1f 100644 --- a/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java +++ b/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java @@ -45,6 +45,7 @@ public class QuerySenderListener extends AbstractSolrEventListener { } @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher) { final SolrIndexSearcher searcher = newSearcher; log.debug("QuerySenderListener sending requests to {}", newSearcher); diff --git a/solr/core/src/java/org/apache/solr/core/RequestParams.java b/solr/core/src/java/org/apache/solr/core/RequestParams.java index 9a5249b71c5..18839539800 100644 --- a/solr/core/src/java/org/apache/solr/core/RequestParams.java +++ b/solr/core/src/java/org/apache/solr/core/RequestParams.java @@ -47,10 +47,12 @@ import static org.apache.solr.common.util.Utils.getDeepCopy; public class RequestParams implements MapSerializable { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + @SuppressWarnings({"rawtypes"}) private final Map data; private final Map paramsets = new LinkedHashMap<>(); private final int znodeVersion; + @SuppressWarnings({"rawtypes"}) public RequestParams(Map data, int znodeVersion) { if (data == null) data = Collections.EMPTY_MAP; this.data = data; @@ -67,6 +69,7 @@ public class RequestParams implements MapSerializable { this.znodeVersion = znodeVersion; } + @SuppressWarnings({"rawtypes"}) public static ParamSet createParamSet(Map map, Long version) { Map copy = getDeepCopy(map, 3); Map meta = (Map) copy.remove(""); @@ -82,9 +85,13 @@ public class RequestParams implements MapSerializable { * This converts Lists to arrays of strings. Because Solr expects * params to be String[] */ + + @SuppressWarnings({"unchecked", "rawtypes"}) private static Map getMapCopy(Map value) { + @SuppressWarnings({"rawtypes"}) Map copy = new LinkedHashMap<>(); for (Object o1 : value.entrySet()) { + @SuppressWarnings({"rawtypes"}) Map.Entry entry = (Map.Entry) o1; if ("".equals(entry.getKey())) { copy.put(entry.getKey(), entry.getValue()); @@ -92,6 +99,7 @@ public class RequestParams implements MapSerializable { } if (entry.getValue() != null) { if (entry.getValue() instanceof List) { + @SuppressWarnings({"rawtypes"}) List l = (List) entry.getValue(); String[] sarr = new String[l.size()]; for (int i = 0; i < l.size(); i++) { @@ -122,10 +130,12 @@ public class RequestParams implements MapSerializable { } @Override + @SuppressWarnings({"unchecked"}) public Map toMap(Map map) { return getMapWithVersion(data, znodeVersion); } + @SuppressWarnings({"unchecked", "rawtypes"}) public static Map getMapWithVersion(Map data, int znodeVersion) { Map result = new LinkedHashMap(); result.put(ConfigOverlay.ZNODEVER, znodeVersion); @@ -133,6 +143,7 @@ public class RequestParams implements MapSerializable { return result; } + @SuppressWarnings({"unchecked", "rawtypes"}) public RequestParams setParams(String name, ParamSet paramSet) { Map deepCopy = getDeepCopy(data, 3); Map p = (Map) deepCopy.get(NAME); @@ -182,6 +193,7 @@ public class RequestParams implements MapSerializable { log.info("conf resource {} loaded . version : {} ", name, version); } try { + @SuppressWarnings({"rawtypes"}) Map m = (Map) fromJSON (in); return new Object[]{m, version}; } catch (Exception e) { @@ -206,10 +218,13 @@ public class RequestParams implements MapSerializable { public static final String INVARIANTS = "_invariants_"; public static class ParamSet implements MapSerializable { + @SuppressWarnings({"rawtypes"}) private final Map defaults, appends, invariants; Map paramsMap; + @SuppressWarnings({"rawtypes"}) public final Map meta; + @SuppressWarnings({"rawtypes"}) ParamSet(Map defaults, Map invariants, Map appends, Map meta) { this.defaults = defaults; this.invariants = invariants; @@ -227,6 +242,7 @@ public class RequestParams implements MapSerializable { } @Override + @SuppressWarnings({"unchecked"}) public Map toMap(Map result) { result.putAll(defaults); 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); return new ParamSet( 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) { if (m1 == null && m2 == null) return null; if (m1 == null) return m2; @@ -263,6 +281,7 @@ public class RequestParams implements MapSerializable { /**get the raw map */ + @SuppressWarnings({"unchecked"}) public Map get() { return defaults; } @@ -271,6 +290,7 @@ public class RequestParams implements MapSerializable { public static class VersionedParams extends MapSolrParams { final ParamSet paramSet; + @SuppressWarnings({"unchecked", "rawtypes"}) public VersionedParams(Map map, ParamSet paramSet) { super(getMapCopy(map)); this.paramSet = paramSet; diff --git a/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java b/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java index 8a591c83381..6fc3629ad1e 100644 --- a/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java +++ b/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java @@ -73,6 +73,7 @@ public class SchemaCodecFactory extends CodecFactory implements SolrCoreAware { } @Override + @SuppressWarnings({"rawtypes"}) public void init(NamedList args) { super.init(args); assert codec == null; diff --git a/solr/core/src/java/org/apache/solr/core/SimpleTextCodecFactory.java b/solr/core/src/java/org/apache/solr/core/SimpleTextCodecFactory.java index de0124fce82..9f3929aa7f5 100644 --- a/solr/core/src/java/org/apache/solr/core/SimpleTextCodecFactory.java +++ b/solr/core/src/java/org/apache/solr/core/SimpleTextCodecFactory.java @@ -25,6 +25,7 @@ public class SimpleTextCodecFactory extends CodecFactory { private Codec codec; @Override + @SuppressWarnings({"rawtypes"}) public void init(NamedList args) { super.init(args); assert codec == null; diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java index 68179ef2ee0..a38e800743c 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java +++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java @@ -368,11 +368,13 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable { public static class SolrPluginInfo { + @SuppressWarnings({"rawtypes"}) public final Class clazz; public final String tag; public final Set options; + @SuppressWarnings({"unchecked", "rawtypes"}) private SolrPluginInfo(Class clz, String tag, PluginOpts... opts) { this.clazz = clz; this.tag = tag; @@ -389,6 +391,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable { } } + @SuppressWarnings({"unchecked", "rawtypes"}) public static ConfigOverlay getConfigOverlay(SolrResourceLoader loader) { InputStream in = null; InputStreamReader isr = null; @@ -672,6 +675,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable { @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public Map toMap(Map map) { LinkedHashMap result = new LinkedHashMap(); result.put("indexWriter", makeMap("closeWaitsForMerges", indexWriterCloseWaitsForMerges)); @@ -706,6 +710,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable { * SearchComponent, QueryConverter, SolrEventListener, DirectoryFactory, * IndexDeletionPolicy, IndexReaderFactory, {@link TransformerFactory} */ + @SuppressWarnings({"unchecked", "rawtypes"}) public List getPluginInfos(String type) { List result = pluginStore.get(type); SolrPluginInfo info = classVsSolrPluginInfo.get(type); @@ -856,6 +861,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable { } @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public Map toMap(Map result) { if (getZnodeVersion() > -1) result.put(ZNODEVER, getZnodeVersion()); result.put(IndexSchema.LUCENE_MATCH_VERSION_PARAM, luceneMatchVersion); @@ -914,6 +920,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable { return result; } + @SuppressWarnings({"unchecked", "rawtypes"}) private void addCacheConfig(Map queryMap, CacheConfig... cache) { if (cache == null) return; for (CacheConfig config : cache) if (config != null) queryMap.put(config.getNodeName(), config); diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index 311e30c7c36..d7bd4c08a2b 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -196,6 +196,7 @@ public final class SolrCore implements SolrInfoBean, Closeable { private final SolrConfig solrConfig; private final SolrResourceLoader resourceLoader; private volatile IndexSchema schema; + @SuppressWarnings({"rawtypes"}) private final NamedList configSetProperties; private final String dataDir; private final String ulogDir; @@ -354,6 +355,7 @@ public final class SolrCore implements SolrInfoBean, Closeable { this.schema = replacementSchema; } + @SuppressWarnings({"rawtypes"}) public NamedList getConfigSetProperties() { return configSetProperties; } @@ -2018,7 +2020,7 @@ public final class SolrCore implements SolrInfoBean, Closeable { } - public RefCounted getSearcher(boolean forceNew, boolean returnSearcher, final Future[] waitSearcher) { + public RefCounted getSearcher(boolean forceNew, boolean returnSearcher, @SuppressWarnings({"rawtypes"})final Future[] waitSearcher) { 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 updateHandlerReopens if true, the UpdateHandler will be used when reopening a {@link SolrIndexSearcher}. */ - public RefCounted getSearcher(boolean forceNew, boolean returnSearcher, final Future[] waitSearcher, boolean updateHandlerReopens) { + public RefCounted 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 // sure that two threads aren't trying to open one at the same time // if it isn't necessary. @@ -2321,6 +2323,7 @@ public final class SolrCore implements SolrInfoBean, Closeable { final SolrIndexSearcher currSearcher = currSearcherHolder == null ? null : currSearcherHolder.get(); + @SuppressWarnings({"rawtypes"}) Future future = null; // 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 transformerFactories = new PluginBag<>(TransformerFactory.class, this); + @SuppressWarnings({"unchecked"}) Map createInstances(Map> map) { Map result = new LinkedHashMap<>(map.size(), 1); for (Map.Entry> e : map.entrySet()) { @@ -2851,7 +2855,7 @@ public final class SolrCore implements SolrInfoBean, Closeable { return def; } - public void initDefaultPlugin(Object plugin, Class type) { + public void initDefaultPlugin(Object plugin, @SuppressWarnings({"rawtypes"})Class type) { if (plugin instanceof SolrMetricProducer) { 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"); + @SuppressWarnings({"unchecked", "rawtypes"}) public List getImplicitHandlers() { List implicits = new ArrayList<>(); 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) * @return a reference to the blob that has already cached the decoded version. */ + @SuppressWarnings({"rawtypes"}) public BlobRepository.BlobContentRef loadDecodeAndCacheBlob(String key, BlobRepository.Decoder decoder) { // make sure component authors don't give us oddball keys with no version... 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"); } // define the blob + @SuppressWarnings({"rawtypes"}) BlobRepository.BlobContentRef blobRef = coreContainer.getBlobRepository().getBlobIncRef(key, decoder); addCloseHook(new CloseHook() { @Override diff --git a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java index 71c69a3409f..6c4c9eca47c 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java +++ b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java @@ -48,7 +48,7 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements NamedList private int maxOptimizedCommitsToKeep = 0; @Override - public void init(NamedList args) { + public void init(@SuppressWarnings("rawtypes") NamedList args) { String keepOptimizedOnlyString = (String) args.get("keepOptimizedOnly"); String maxCommitsToKeepString = (String) args.get("maxCommitsToKeep"); String maxOptimizedCommitsToKeepString = (String) args.get("maxOptimizedCommitsToKeep"); diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java index 9678d689709..f4fcecde845 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java +++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java @@ -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 public T newInstance(String name, Class expectedType) { return newInstance(name, expectedType, empty); } + @SuppressWarnings({"rawtypes"}) private static final Class[] NO_CLASSES = new Class[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); } + @SuppressWarnings({"rawtypes"}) public T newInstance(String cName, Class expectedType, String[] subPackages, Class[] params, Object[] args) { Class clazz = findClass(cName, expectedType, subPackages); 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 */ + @SuppressWarnings({"rawtypes"}) private static final Map awareCompatibility; static { awareCompatibility = new HashMap<>(); awareCompatibility.put( - SolrCoreAware.class, new Class[]{ + SolrCoreAware.class, new Class[]{ // 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 CodecFactory.class, @@ -708,7 +711,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable { ); awareCompatibility.put( - ResourceLoaderAware.class, new Class[]{ + ResourceLoaderAware.class, new Class[]{ // 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 CharFilterFactory.class, @@ -723,6 +726,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable { /** * Utility function to throw an exception if the class is invalid */ + @SuppressWarnings({"rawtypes"}) public static void assertAwareCompatibility(Class aware, Object obj) { Class[] valid = awareCompatibility.get(aware); if (valid == null) { diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java index 5de4643e5fb..f579c775f8d 100644 --- a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java +++ b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java @@ -54,6 +54,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache { // deprecate this for 7.0? this.cacheSize = cfg.getTransientCacheSize(); } else { + @SuppressWarnings({"rawtypes"}) NamedList args = cfg.getTransientCachePluginInfo().initArgs; Object obj = args.get("transientCacheSize"); 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. this.cacheSize = cfg.getTransientCacheSize(); } else { + @SuppressWarnings({"rawtypes"}) NamedList args = cfg.getTransientCachePluginInfo().initArgs; Object obj = args.get("transientCacheSize"); if (obj != null) { @@ -105,6 +107,8 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache { @Override public Collection prepareForShutdown() { // Return a copy of the values + + @SuppressWarnings({"unchecked", "rawtypes"}) List ret = new ArrayList(transientCores.values()); transientCores.clear(); return ret; @@ -129,7 +133,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache { } // 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 public SolrCore removeCore(String name) { return transientCores.remove(name); diff --git a/solr/core/src/java/org/apache/solr/core/backup/repository/HdfsBackupRepository.java b/solr/core/src/java/org/apache/solr/core/backup/repository/HdfsBackupRepository.java index 6c0b04c3f72..1e9da27451e 100644 --- a/solr/core/src/java/org/apache/solr/core/backup/repository/HdfsBackupRepository.java +++ b/solr/core/src/java/org/apache/solr/core/backup/repository/HdfsBackupRepository.java @@ -49,6 +49,7 @@ public class HdfsBackupRepository implements BackupRepository { private Configuration hdfsConfig = null; private FileSystem fileSystem = null; private Path baseHdfsPath = null; + @SuppressWarnings("rawtypes") private NamedList config = null; protected int copyBufferSize = HdfsDirectory.DEFAULT_BUFFER_SIZE; diff --git a/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java b/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java index 2379b0dd7be..612a61fd4bf 100644 --- a/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java +++ b/solr/core/src/java/org/apache/solr/core/backup/repository/LocalFileSystemRepository.java @@ -46,10 +46,11 @@ import com.google.common.base.Preconditions; * interface e.g. NFS). */ public class LocalFileSystemRepository implements BackupRepository { + @SuppressWarnings("rawtypes") private NamedList config = null; @Override - public void init(NamedList args) { + public void init(@SuppressWarnings("rawtypes") NamedList args) { this.config = args; } diff --git a/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotManager.java b/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotManager.java index f40bea80558..3a9fa0ef1b8 100644 --- a/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotManager.java +++ b/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotManager.java @@ -169,6 +169,7 @@ public class SolrSnapshotManager { throws InterruptedException, KeeperException { String zkPath = getSnapshotMetaDataZkPath(collectionName, Optional.of(commitName)); try { + @SuppressWarnings({"unchecked"}) Map data = (Map)Utils.fromJSON(zkClient.getData(zkPath, null, null, true)); return Optional.of(new CollectionSnapshotMetaData(data)); } catch (KeeperException ex) { @@ -281,13 +282,14 @@ public class SolrSnapshotManager { * @param dir The index directory storing the snapshot. * @throws IOException in case of I/O errors. */ + + @SuppressWarnings({"try", "unused"}) private static void deleteSnapshotIndexFiles(SolrCore core, Directory dir, IndexDeletionPolicy delPolicy) throws IOException { IndexWriterConfig conf = core.getSolrConfig().indexConfig.toIndexWriterConfig(core); conf.setOpenMode(OpenMode.APPEND); conf.setMergePolicy(NoMergePolicy.INSTANCE);//Don't want to merge any commits here! conf.setIndexDeletionPolicy(delPolicy); conf.setCodec(core.getCodec()); - try (SolrIndexWriter iw = new SolrIndexWriter("SolrSnapshotCleaner", dir, conf)) { // 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. diff --git a/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotsTool.java b/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotsTool.java index 31323aa9451..4d4c3b829af 100644 --- a/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotsTool.java +++ b/solr/core/src/java/org/apache/solr/core/snapshots/SolrSnapshotsTool.java @@ -426,6 +426,7 @@ public class SolrSnapshotsTool implements Closeable, CLIO { return false; } + @SuppressWarnings({"unchecked", "rawtypes"}) private Collection listCollectionSnapshots(String collectionName) throws SolrServerException, IOException { CollectionAdminRequest.ListSnapshots listSnapshots = new CollectionAdminRequest.ListSnapshots(collectionName); diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java index f78e523ed2d..0ef3ebbd999 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java @@ -114,7 +114,7 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa @Override - final public void init(NamedList args) { + final public void init(@SuppressWarnings({"rawtypes"})NamedList args) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "CoreAdminHandler should not be configured in solrconf.xml\n" + "it is a special Handler configured directly by the RequestDispatcher"); diff --git a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java index 380bc9acca1..eddd5b795fd 100644 --- a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java +++ b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java @@ -196,9 +196,10 @@ public abstract class SolrCoreState { public abstract void setCdcrBootstrapFuture(Future cdcrBootstrapFuture); + @SuppressWarnings("rawtypes") public abstract Callable getCdcrBootstrapCallable(); - public abstract void setCdcrBootstrapCallable(Callable cdcrBootstrapCallable); + public abstract void setCdcrBootstrapCallable(@SuppressWarnings("rawtypes") Callable cdcrBootstrapCallable); public Throwable getTragicException() throws IOException { RefCounted ref = getIndexWriter(null);