private static <T extends ConfigInstance> JarConfigSubscription<T> getJarSub(ConfigKey<T> key, ConfigSource source) {
        String jarName;
        String path = "config/";
        if (source instanceof JarSource js) {
            jarName = js.getJarFile().getName();
            if (js.getPath() != null) path = js.getPath();
        } else {
            jarName = key.getConfigId().replace("jar:", "").replaceFirst("!/.*", "");
            if (key.getConfigId().contains("!/")) path = key.getConfigId().replaceFirst(".*!/", "");
        }
        return new JarConfigSubscription<>(key, jarName, path);
    }
Correct type of ConfigSubscription instance based on type of source or form of config id

@param key        a {@link ConfigKey}
@return a subclass of a ConfigsSubscription
config/src/main/java/com/yahoo/config/subscription/impl/ConfigSubscription.java