typelevel / typelevel/cats-effect

Over-aggressive Stack Trace Enhancement

Open
#1,513 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:beetle: bug
Dominant language
Scala
Stars
2.2k
Forks
576
Avg merge
2d 11h
Merged PRs (30d)
18

Description

Original:

java.lang.ClassCastException: interface akka.event.LoggingFilter is not assignable from class akka.event.DefaultLoggingFilter
	at akka.actor.ReflectiveDynamicAccess.$anonfun$getClassFor$1(ReflectiveDynamicAccess.scala:31)
	at scala.util.Try$.apply(Try.scala:210)
	at akka.actor.ReflectiveDynamicAccess.getClassFor(ReflectiveDynamicAccess.scala:28)
	at akka.actor.ReflectiveDynamicAccess.createInstanceFor(ReflectiveDynamicAccess.scala:47)
	at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:926)
	at akka.actor.ActorSystem$.apply(ActorSystem.scala:282)
	at akka.actor.ActorSystem$.apply(ActorSystem.scala:326)
	at akka.actor.ActorSystem$.apply(ActorSystem.scala:308)
	at example.PlayWSResource$.$anonfun$res$1(PlayWSResource.scala:20)
	at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:104)
	at cats.effect.internals.IORunLoop$.restartCancelable(IORunLoop.scala:51)
	at cats.effect.internals.IOBracket$BracketStart.run(IOBracket.scala:100)
	at cats.effect.internals.Trampoline.cats$effect$internals$Trampoline$$immediateLoop(Trampoline.scala:67)
	at cats.effect.internals.Trampoline.startLoop(Trampoline.scala:35)
	at cats.effect.internals.TrampolineEC$JVMTrampoline.super$startLoop(TrampolineEC.scala:90)
	at cats.effect.internals.TrampolineEC$JVMTrampoline.$anonfun$startLoop$1(TrampolineEC.scala:90)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
	at cats.effect.internals.TrampolineEC$JVMTrampoline.startLoop(TrampolineEC.scala:90)
	at cats.effect.internals.Trampoline.execute(Trampoline.scala:43)
	at cats.effect.internals.TrampolineEC.execute(TrampolineEC.scala:42)
	at cats.effect.internals.IOBracket$BracketStart.apply(IOBracket.scala:80)
	at cats.effect.internals.IOBracket$BracketStart.apply(IOBracket.scala:58)
	at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:183)
	at cats.effect.internals.IORunLoop$.restart(IORunLoop.scala:41)
	at cats.effect.internals.IOBracket$.$anonfun$apply$1(IOBracket.scala:48)
	at cats.effect.internals.IOBracket$.$anonfun$apply$1$adapted(IOBracket.scala:34)
	at cats.effect.internals.IOAsync$.$anonfun$apply$1(IOAsync.scala:37)
	at cats.effect.internals.IOAsync$.$anonfun$apply$1$adapted(IOAsync.scala:37)
	at cats.effect.internals.IORunLoop$RestartCallback.start(IORunLoop.scala:447)
	at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:156)
	at cats.effect.internals.IORunLoop$RestartCallback.signal(IORunLoop.scala:463)
	at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:484)
	at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:422)
	at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:183)
	at cats.effect.internals.IORunLoop$RestartCallback.signal(IORunLoop.scala:463)
	at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:484)
	at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:422)
	at cats.effect.internals.IOShift$Tick.run(IOShift.scala:36)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)

Enhanced:

java.lang.ClassCastException: interface akka.event.LoggingFilter is not assignable from class akka.event.DefaultLoggingFilter
	at akka.actor.ReflectiveDynamicAccess.$anonfun$getClassFor$1(ReflectiveDynamicAccess.scala:31)
	at make @ example.PlayWSResource$.res(PlayWSResource.scala:42)
	at make @ example.PlayWSResource$.res(PlayWSResource.scala:42)
	at flatMap @ fs2.internal.CompileScope.acquireResource(CompileScope.scala:180)
	at flatMap @ fs2.internal.FreeC$.$anonfun$compile$12(Algebra.scala:511)
	at flatMap @ fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:436)
	at flatMap @ fs2.internal.FreeC$.$anonfun$compile$7(Algebra.scala:463)
	at flatMap @ fs2.internal.FreeC$.go$1(Algebra.scala:460)
	at flatMap @ fs2.internal.CompileScope.$anonfun$open$2(CompileScope.scala:146)
	at flatMap @ fs2.internal.CompileScope.open(CompileScope.scala:141)
	at flatMap @ fs2.internal.FreeC$.$anonfun$compile$15(Algebra.scala:533)
	at flatMap @ fs2.internal.FreeC$.$anonfun$compile$14(Algebra.scala:531)
	at flatMap @ fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:436)
	at flatMap @ fs2.internal.FreeC$.$anonfun$compile$7(Algebra.scala:463)
	at flatMap @ fs2.internal.FreeC$.go$1(Algebra.scala:460)
	at flatMap @ fs2.internal.FreeC$.$anonfun$compile$7(Algebra.scala:463)
	at flatMap @ fs2.internal.FreeC$.go$1(Algebra.scala:460)

Origin: https://github.com/keynmol/weaver-classloader-repro/tree/237e3bcdfb190b49b8360ea8b68ba6f5a15b24e2

Seems a bit aggressive

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction linked at https://github.com/keynmol/weaver-classloader-repro/tree/237e3bcdfb190b49b8360ea8b68ba6f5a15b24e2 and compare the Original and Enhanced traces in the issue. Trace the stack-trace enhancement path that adds the make/flatMap frames. Done means the ClassCastException no longer produces the reported over-aggressive enhancement, with the expected output clarified and checked against this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.