getappmap / appmap-java

AppMap client agent for Java
Other
80 stars 14 forks source link

Ugly error messages when classes not available at runtime #241

Closed apotterri closed 8 months ago

apotterri commented 8 months ago

In Java, it's standard practice for packages that are available at compile time not to be available at runtime. This is often a way to allow multiple implementations of functionality, with the choice of implementation depending on which package is actually provided.

A result of this approach is that there may be methods that match the config, but that have parameters or a return type that javassist can't process. When the agent tries to instrument such a method, it prints out an ugly error message, e.g.

22:02:40.704 [restartedMain] ERROR Logger.println: com.appland.appmap.output.v1.NoSourceAvailableException: Failed to get parameter types for org.springframework.boot.autoconfigure.cache.HazelcastCacheConfiguration.cacheManager(Lorg/springframework/boot/autoconfigure/cache/CacheManagerCustomizers;Lcom/hazelcast/core/HazelcastInstance;)Lcom/hazelcast/spring/cache/HazelcastCacheManager;: com.hazelcast.core.HazelcastInstance
    at com.appland.appmap.output.v1.Parameters.<init>(Parameters.java:59)
    at com.appland.appmap.output.v1.Event.<init>(Event.java:159)
    at com.appland.appmap.record.EventTemplateRegistry.register(EventTemplateRegistry.java:38)
    at com.appland.appmap.transform.annotations.Hook.prepare(Hook.java:133)
    at com.appland.appmap.transform.ClassFileTransformer.lambda$applyHooks$4(ClassFileTransformer.java:147)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at com.appland.appmap.transform.ClassFileTransformer.applyHooks(ClassFileTransformer.java:149)
    at com.appland.appmap.transform.ClassFileTransformer.transform(ClassFileTransformer.java:248)
...

Given that the JVM would object if the application tried to actually call one of these methods, the agent should just ignore them.

appland-release commented 8 months ago

:tada: This issue has been resolved in version 1.25.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: