googleJavaFormat & codeNarc
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/DDCachingPoolStrategy.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/DDCachingPoolStrategy.java
@@ -29,17 +29,17 @@ import net.bytebuddy.pool.TypePool;
* that combines loader ID & name
* </ul>
*
- * <p>This design was chosen to create a single limited size cache that can be adjusted
- * for the entire application -- without having to create a large number of WeakReference objects.
+ * <p>This design was chosen to create a single limited size cache that can be adjusted for the
+ * entire application -- without having to create a large number of WeakReference objects.
*
* <p>The ID assignment mostly assigns a single ID to each ClassLoader, but the maximumSize
* restriction means that an evicted ClassLoader could be assigned another ID later on.
*
- * <p>For the validity of the cache, the important part is that ID assignment guarantees that
- * no two ClassLoaders share the same ID.
+ * <p>For the validity of the cache, the important part is that ID assignment guarantees that no two
+ * ClassLoaders share the same ID.
*
- * <p>NOTE: As an additional safe-guard, a new CacheInstance can be created if the original loader ID
- * sequence is exhausted.
+ * <p>NOTE: As an additional safe-guard, a new CacheInstance can be created if the original loader
+ * ID sequence is exhausted.
*/
@Slf4j
public class DDCachingPoolStrategy implements PoolStrategy {
@@ -192,9 +192,7 @@ public class DDCachingPoolStrategy implements PoolStrategy {
private final TypePool createCachingTypePool(
final long loaderId, final ClassFileLocator classFileLocator) {
return new TypePool.Default.WithLazyResolution(
- createCacheProvider(loaderId),
- classFileLocator,
- TypePool.Default.ReaderMode.FAST);
+ createCacheProvider(loaderId), classFileLocator, TypePool.Default.ReaderMode.FAST);
}
private final TypePool createCachingTypePool(
@@ -255,7 +253,8 @@ public class DDCachingPoolStrategy implements PoolStrategy {
@Override
public TypePool.Resolution find(final String name) {
- TypePool.Resolution existingResolution = sharedResolutionCache.getIfPresent(new TypeCacheKey(cacheId, name));
+ TypePool.Resolution existingResolution =
+ sharedResolutionCache.getIfPresent(new TypeCacheKey(cacheId, name));
if (existingResolution != null) return existingResolution;
if (OBJECT_NAME.equals(name)) {

MODIFY
dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/CacheProviderTest.groovy
dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/CacheProviderTest.groovy
package datadog.trace.agent.tooling
-import datadog.trace.util.gc.GCUtils
import datadog.trace.util.test.DDSpecification
import net.bytebuddy.description.type.TypeDescription
import net.bytebuddy.dynamic.ClassFileLocator
import net.bytebuddy.pool.TypePool
import spock.lang.Timeout
-import java.lang.ref.WeakReference
import java.security.SecureClassLoader
-import java.util.concurrent.TimeUnit
-import java.util.concurrent.atomic.AtomicReference
-
-import static datadog.trace.agent.tooling.AgentTooling.CLEANER
@Timeout(5)
class CacheProviderTest extends DDSpecification {
@@ -52,9 +46,9 @@ class CacheProviderTest extends DDSpecification {
def "test basic caching"() {
setup:
- def cacheInstance = new DDCachingPoolStrategy.CacheInstance();
+ def cacheInstance = new DDCachingPoolStrategy.CacheInstance()
- def cacheProvider = cacheInstance.createCacheProvider(1);
+ def cacheProvider = cacheInstance.createCacheProvider(1)
when:
cacheProvider.register("foo", new TypePool.Resolution.Simple(TypeDescription.VOID))
@@ -67,10 +61,10 @@ class CacheProviderTest extends DDSpecification {
def "test ID equivalence"() {
setup:
- def cacheInstance = new DDCachingPoolStrategy.CacheInstance();
+ def cacheInstance = new DDCachingPoolStrategy.CacheInstance()
- def cacheProvider1A = cacheInstance.createCacheProvider(1);
- def cacheProvider1B = cacheInstance.createCacheProvider(1);
+ def cacheProvider1A = cacheInstance.createCacheProvider(1)
+ def cacheProvider1B = cacheInstance.createCacheProvider(1)
when:
cacheProvider1A.register("foo", newVoid())
@@ -86,10 +80,10 @@ class CacheProviderTest extends DDSpecification {
def "test ID separation"() {
setup:
- def cacheInstance = new DDCachingPoolStrategy.CacheInstance();
+ def cacheInstance = new DDCachingPoolStrategy.CacheInstance()
- def cacheProvider1 = cacheInstance.createCacheProvider(1);
- def cacheProvider2 = cacheInstance.createCacheProvider(2);
+ def cacheProvider1 = cacheInstance.createCacheProvider(1)
+ def cacheProvider2 = cacheInstance.createCacheProvider(2)
when:
cacheProvider1.register("foo", newVoid())
@@ -173,8 +167,8 @@ class CacheProviderTest extends DDSpecification {
def cacheInstance = new DDCachingPoolStrategy.CacheInstance()
def capacity = DDCachingPoolStrategy.CacheInstance.TYPE_CAPACITY
- def cacheProvider1 = cacheInstance.createCacheProvider(1);
- def cacheProvider2 = cacheInstance.createCacheProvider(2);
+ def cacheProvider1 = cacheInstance.createCacheProvider(1)
+ def cacheProvider2 = cacheInstance.createCacheProvider(2)
def id = 0
@@ -201,15 +195,15 @@ class CacheProviderTest extends DDSpecification {
cacheInstance.approximateSize() > capacity - 4
}
- static def newVoid() {
+ static newVoid() {
return new TypePool.Resolution.Simple(TypeDescription.VOID)
}
- static def newClassLoader() {
- return new SecureClassLoader(null) {};
+ static newClassLoader() {
+ return new SecureClassLoader(null) {}
}
- static def newLocator() {
+ static newLocator() {
return new ClassFileLocator() {
@Override
ClassFileLocator.Resolution locate(String name) throws IOException {

googleJavaFormat & codeNarc