apache / pekko-grpc

Apache Pekko gRPC
https://pekko.apache.org/
Apache License 2.0
38 stars 16 forks source link

java.lang.NullPointerException in GrpcExceptionHandlerSpec #184

Open He-Pin opened 10 months ago

He-Pin commented 10 months ago
[ERROR] [10/12/2023 15:08:18.179] [pool-9-thread-9-ScalaTest-running-GrpcExceptionHandlerSpec] [org.apache.pekko.grpc.scaladsl.GrpcExceptionHandler(pekko://Test)] Unhandled error: [null]rpcClientSettingsSpec 0s
java.lang.NullPointerException
        at org.apache.pekko.grpc.scaladsl.GrpcExceptionHandlerSpec.<init>(GrpcExceptionHandlerSpec.scala:53)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:454)
        at sbt.TestRunner.runTest$1(TestFramework.scala:153)
        at sbt.TestRunner.run(TestFramework.scala:168)
        at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.$anonfun$apply$1(TestFramework.scala:336)
        at sbt.TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:296)
        at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:336)
        at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:336)
        at sbt.TestFunction.apply(TestFramework.scala:348)
        at sbt.Tests$.$anonfun$toTask$1(Tests.scala:436)
        at sbt.std.Transform$$anon$3.$anonfun$apply$2(Transform.scala:47)
        at sbt.std.Transform$$anon$4.work(Transform.scala:69)
        at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
        at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
        at sbt.Execute.work(Execute.scala:292)
        at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
        at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
raboof commented 10 months ago

The test succeeds, and I think it's generally intentional that this exception is logged.

Instead of sending it to the console when running the test, though, we should probably capture the log output and verify as part of the test that it is found in there.

laglangyue commented 4 months ago

image

GrpcExceptionHandlerSpec test exception assertion will record an error log to the console.

Do we have a way to temporarily set Log off ? @raboof @He-Pin So we can separate test for NullPointerException and RuntimeException, and set Log off

raboof commented 4 months ago

Perhaps we could use LogCapturing (https://pekko.apache.org/docs/pekko/current/typed/testing-async.html#silence-logging-output-from-tests)