|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2021 DiffPlug |
| 2 | + * Copyright 2016-2023 DiffPlug |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
27 | 27 |
|
28 | 28 | import javax.annotation.Nullable;
|
29 | 29 |
|
| 30 | +import org.slf4j.Logger; |
| 31 | +import org.slf4j.LoggerFactory; |
| 32 | + |
30 | 33 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
31 | 34 |
|
32 | 35 | /**
|
33 | 36 | * Spotless' global cache. {@link SpotlessCache#clear()} should be called
|
34 | 37 | * when Spotless is no longer in use to release any resources it has grabbed.
|
35 | 38 | */
|
36 | 39 | public final class SpotlessCache {
|
| 40 | + private static final Logger LOGGER = LoggerFactory.getLogger(SpotlessCache.class); |
| 41 | + |
37 | 42 | /** Allows comparing keys based on their serialization. */
|
38 | 43 | static final class SerializedKey {
|
39 | 44 | final byte[] serialized;
|
@@ -68,7 +73,10 @@ synchronized ClassLoader classloader(JarState state) {
|
68 | 73 | synchronized ClassLoader classloader(Serializable key, JarState state) {
|
69 | 74 | SerializedKey serializedKey = new SerializedKey(key);
|
70 | 75 | return cache
|
71 |
| - .computeIfAbsent(serializedKey, k -> new FeatureClassLoader(state.jarUrls(), this.getClass().getClassLoader())); |
| 76 | + .computeIfAbsent(serializedKey, k -> { |
| 77 | + LOGGER.debug("Allocating an additional FeatureClassLoader for key={} Cache.size was {}", key, cache.size()); |
| 78 | + return new FeatureClassLoader(state.jarUrls(), this.getClass().getClassLoader()); |
| 79 | + }); |
72 | 80 | }
|
73 | 81 |
|
74 | 82 | static SpotlessCache instance() {
|
|
0 commit comments