Skip to content

Commit

Permalink
Use compiler args
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohora committed Jan 10, 2025
1 parent f6050e6 commit dbeeb59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions apps/opik-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@
<artifactId>mvel2</artifactId>
<version>2.5.2.Final</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.paranamer</groupId>
<artifactId>paranamer</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
Expand Down Expand Up @@ -452,6 +447,9 @@
<configuration>
<source>21</source>
<target>21</target>
<compilerArgument>-parameters</compilerArgument>
<parameters>true</parameters>
<testCompilerArgument>-parameters</testCompilerArgument>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.comet.opik.infrastructure.CacheConfiguration;
import com.comet.opik.utils.TypeReferenceUtils;
import com.fasterxml.jackson.core.type.TypeReference;
import com.thoughtworks.paranamer.BytecodeReadingParanamer;
import jakarta.inject.Provider;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -13,6 +12,7 @@
import reactor.core.publisher.Mono;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.time.Duration;
import java.util.Collection;
import java.util.HashMap;
Expand All @@ -25,7 +25,6 @@
@RequiredArgsConstructor
public class CacheInterceptor implements MethodInterceptor {

private static final BytecodeReadingParanamer PARANAMER = new BytecodeReadingParanamer();
private final Provider<CacheManager> cacheManager;
private final CacheConfiguration cacheConfiguration;

Expand Down Expand Up @@ -189,13 +188,13 @@ private String getKeyName(String name, String key, MethodInvocation invocation)
Map<String, Object> params = new HashMap<>();

// Use Paranamer to resolve parameter names
String[] parameters = PARANAMER.lookupParameterNames(invocation.getMethod());
Parameter[] parameters = invocation.getMethod().getParameters();
Object[] args = invocation.getArguments();

// Populate the context map with parameter names and values
for (int i = 0; i < invocation.getMethod().getParameterCount(); i++) {
Object value = args[i];
params.put("$" + parameters[i], value != null ? value : ""); // Null safety
params.put("$" + parameters[i].getName(), value != null ? value : ""); // Null safety
}

try {
Expand Down

0 comments on commit dbeeb59

Please sign in to comment.