class CacheUtil {

    private static final Logger LOGGER = LoggerFactory.getLogger(CacheUtil.class);

    private CacheUtil() {
        // private to enforce static
    }

    /**
     *
     * @param repository {@link RepositoryInfo} instance
     * @param cache {@link Cache} instance
     * @return absolute directory path for top level cache directory of given repository.
     * Will return {@code null} on error.
     */
    @VisibleForTesting
    @Nullable
    public static String getRepositoryCacheDataDirname(RepositoryInfo repository, Cache cache) {
        String repoDirBasename;

        RuntimeEnvironment env = RuntimeEnvironment.getInstance();

        try {
            repoDirBasename = env.getPathRelativeToSourceRoot(new File(repository.getDirectoryName()));
        } catch (IOException ex) {
            LOGGER.log(Level.WARNING,
                    String.format("Could not resolve repository '%s' relative to source root", repository), ex);
            return null;
        } catch (ForbiddenSymlinkException ex) {
            LOGGER.log(Level.FINER, ex.getMessage());
            return null;
        }

        return env.getDataRootPath() + File.separatorChar
                + cache.getCacheDirName()
                + repoDirBasename;
    }

    public static void clearCacheDir(RepositoryInfo repository, Cache cache) {<FILL_FUNCTION_BODY>}
}

        String histDir = CacheUtil.getRepositoryCacheDataDirname(repository, cache);
        if (histDir != null) {
            // Remove all files which constitute the history cache.
            try {
                IOUtils.removeRecursive(Paths.get(histDir));
            } catch (NoSuchFileException ex) {
                LOGGER.log(Level.WARNING, String.format("directory '%s' does not exist", histDir));
            } catch (IOException ex) {
                LOGGER.log(Level.SEVERE, "tried removeRecursive()", ex);
            }
        }
    
<no_super_class>