@Override
    public ClassLoaderLease registerClassLoaderLease(JobID jobId) {
        synchronized (lockObject) {
            return cacheEntries
                    .computeIfAbsent(jobId, jobID -> new LibraryCacheEntry(jobId))
                    .obtainLease();
        }
    }
@Test
    public void closingAllLeases_willReleaseUserCodeClassLoader() throws IOException {
        final TestingClassLoader classLoader = new TestingClassLoader();
        final BlobLibraryCacheManager libraryCacheManager =
                new TestingBlobLibraryCacheManagerBuilder()
                        .setClassLoaderFactory(ignored -> classLoader)
                        .build();

        final JobID jobId = new JobID();
        final LibraryCacheManager.ClassLoaderLease classLoaderLease1 =
                libraryCacheManager.registerClassLoaderLease(jobId);
        final LibraryCacheManager.ClassLoaderLease classLoaderLease2 =
                libraryCacheManager.registerClassLoaderLease(jobId);

        UserCodeClassLoader userCodeClassLoader =
                classLoaderLease1.getOrResolveClassLoader(
                        Collections.emptyList(), Collections.emptyList());

        classLoaderLease1.release();

        assertFalse(classLoader.isClosed());

        classLoaderLease2.release();

        if (wrapsSystemClassLoader) {
            assertEquals(userCodeClassLoader.asClassLoader(), ClassLoader.getSystemClassLoader());
            assertFalse(classLoader.isClosed());
        } else {
            assertTrue(classLoader.isClosed());
        }
    }