Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetricsFilter has IndexOutOfBoundsException with Keycloak 25 #214

Open
zhechense opened this issue Sep 3, 2024 · 0 comments
Open

MetricsFilter has IndexOutOfBoundsException with Keycloak 25 #214

zhechense opened this issue Sep 3, 2024 · 0 comments

Comments

@zhechense
Copy link

zhechense commented Sep 3, 2024

Description

I upgraded Keycloak from version 23 to 25 and also updated my SPI library to keycloak-metrics-spi-6.0.0.jar. After these updates, the /auth/metrics API started throwing IndexOutOfBoundsException. It seems that uriInfo.getMatchedURIs() is returning an empty list, causing uriInfo.getMatchedURIs().get(0) to throw an exception.

Any ideas how can I fix this?

{
   "timestamp":"2024-09-02T12:59:47.729705Z",
   "sequence":10611,
   "loggerClassName":"org.jboss.logging.Logger",
   "loggerName":"io.quarkus.vertx.http.runtime.QuarkusErrorHandler",
   "level":"ERROR",
   "message":"HTTP Request to /auth/metrics failed, error id: 1d6214f7-f25b-442b-91d0-baf649cac314-62",
   "threadName":"vert.x-eventloop-thread-3",
   "threadId":89,
   "mdc":{
      "trace_flags":"01",
      "trace_id":"240ff85f24376b3287e4f17b26955b81",
      "span_id":"1fbaa0d82507901b"
   },
   "ndc":"",
   "hostName":"keycloak-green-59f87f7f8-gbk4v",
   "processName":"QuarkusEntryPoint",
   "processId":1,
   "exception":{
      "refId":1,
      "exceptionType":"java.lang.IndexOutOfBoundsException",
      "message":"Index: 0",
      "frames":[
         {
            "class":"java.util.Collections$EmptyList",
            "method":"get",
            "line":4807
         },
         {
            "class":"org.jboss.aerogear.keycloak.metrics.ResourceExtractor",
            "method":"getURI",
            "line":74
         },
         {
            "class":"org.jboss.aerogear.keycloak.metrics.MetricsFilter",
            "method":"filter",
            "line":53
         },
         {
            "class":"org.jboss.aerogear.keycloak.metrics.MetricsFilterProvider",
            "method":"filter",
            "line":26
         },
         {
            "class":"org.jboss.resteasy.reactive.server.handlers.ResourceResponseFilterHandler",
            "method":"handle",
            "line":25
         },
         {
            "class":"io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext",
            "method":"invokeHandler",
            "line":150
         },
         {
            "class":"org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext",
            "method":"run",
            "line":147
         },
         {
            "class":"org.jboss.resteasy.reactive.server.handlers.RestInitialHandler",
            "method":"beginProcessing",
            "line":48
         },
         {
            "class":"org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler",
            "method":"handle",
            "line":23
         },
         {
            "class":"org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler",
            "method":"handle",
            "line":10
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":39
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":21
         },
         {
            "class":"io.vertx.ext.web.impl.RouteState",
            "method":"handleContext",
            "line":1285
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextImplBase",
            "method":"iterateNext",
            "line":177
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextWrapper",
            "method":"next",
            "line":200
         },
         {
            "class":"io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1",
            "method":"handle",
            "line":62
         },
         {
            "class":"io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1",
            "method":"handle",
            "line":40
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":39
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":21
         },
         {
            "class":"io.vertx.ext.web.impl.RouteState",
            "method":"handleContext",
            "line":1285
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextImplBase",
            "method":"iterateNext",
            "line":177
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextWrapper",
            "method":"next",
            "line":200
         },
         {
            "class":"io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13",
            "method":"handle",
            "line":339
         },
         {
            "class":"io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13",
            "method":"handle",
            "line":332
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":39
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":21
         },
         {
            "class":"io.vertx.ext.web.impl.RouteState",
            "method":"handleContext",
            "line":1285
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextImplBase",
            "method":"iterateNext",
            "line":177
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextWrapper",
            "method":"next",
            "line":200
         },
         {
            "class":"io.vertx.ext.web.impl.RouterImpl",
            "method":"handleContext",
            "line":250
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":39
         },
         {
            "class":"io.opentelemetry.javaagent.instrumentation.vertx.RoutingContextHandlerWrapper",
            "method":"handle",
            "line":21
         },
         {
            "class":"io.vertx.ext.web.impl.RouteState",
            "method":"handleContext",
            "line":1285
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextImplBase",
            "method":"iterateNext",
            "line":177
         },
         {
            "class":"io.vertx.ext.web.impl.RoutingContextImpl",
            "method":"next",
            "line":137
         },
         {
            "class":"io.vertx.ext.web.impl.RouterImpl",
            "method":"handle",
            "line":68
         },
         {
            "class":"io.vertx.ext.web.impl.RouterImpl",
            "method":"handle",
            "line":37
         },
         {
            "class":"io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$3",
            "method":"handle",
            "line":103
         },
         {
            "class":"io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$3",
            "method":"handle",
            "line":100
         },
         {
            "class":"io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$2",
            "method":"handle",
            "line":86
         },
         {
            "class":"io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$2",
            "method":"handle",
            "line":69
         },
         {
            "class":"io.quarkus.vertx.http.runtime.VertxHttpRecorder$1",
            "method":"handle",
            "line":147
         },
         {
            "class":"io.quarkus.vertx.http.runtime.VertxHttpRecorder$1",
            "method":"handle",
            "line":123
         },
         {
            "class":"io.vertx.core.impl.ContextImpl",
            "method":"emit",
            "line":328
         },
         {
            "class":"io.vertx.core.impl.DuplicatedContext",
            "method":"emit",
            "line":166
         },
         {
            "class":"io.vertx.core.http.impl.Http1xServerConnection",
            "method":"handleMessage",
            "line":174
         },
         {
            "class":"io.vertx.core.net.impl.ConnectionBase",
            "method":"read",
            "line":159
         },
         {
            "class":"io.vertx.core.net.impl.VertxHandler",
            "method":"channelRead",
            "line":153
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":442
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":420
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"fireChannelRead",
            "line":412
         },
         {
            "class":"io.netty.handler.timeout.IdleStateHandler",
            "method":"channelRead",
            "line":289
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":442
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":420
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"fireChannelRead",
            "line":412
         },
         {
            "class":"io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext",
            "method":"fireChannelRead",
            "line":436
         },
         {
            "class":"io.netty.channel.ChannelInboundHandlerAdapter",
            "method":"channelRead",
            "line":93
         },
         {
            "class":"io.opentelemetry.javaagent.shaded.instrumentation.netty.v4_1.internal.server.HttpServerRequestTracingHandler",
            "method":"channelRead",
            "line":57
         },
         {
            "class":"io.netty.channel.CombinedChannelDuplexHandler",
            "method":"channelRead",
            "line":251
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":442
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":420
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"fireChannelRead",
            "line":412
         },
         {
            "class":"io.netty.channel.ChannelInboundHandlerAdapter",
            "method":"channelRead",
            "line":93
         },
         {
            "class":"io.opentelemetry.javaagent.shaded.instrumentation.netty.v4_1.internal.server.HttpServerRequestTracingHandler",
            "method":"channelRead",
            "line":65
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":444
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":420
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"fireChannelRead",
            "line":412
         },
         {
            "class":"io.netty.handler.codec.ByteToMessageDecoder",
            "method":"fireChannelRead",
            "line":346
         },
         {
            "class":"io.netty.handler.codec.ByteToMessageDecoder",
            "method":"channelRead",
            "line":318
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":444
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":420
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"fireChannelRead",
            "line":412
         },
         {
            "class":"io.netty.channel.DefaultChannelPipeline$HeadContext",
            "method":"channelRead",
            "line":1410
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":440
         },
         {
            "class":"io.netty.channel.AbstractChannelHandlerContext",
            "method":"invokeChannelRead",
            "line":420
         },
         {
            "class":"io.netty.channel.DefaultChannelPipeline",
            "method":"fireChannelRead",
            "line":919
         },
         {
            "class":"io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe",
            "method":"read",
            "line":166
         },
         {
            "class":"io.netty.channel.nio.NioEventLoop",
            "method":"processSelectedKey",
            "line":788
         },
         {
            "class":"io.netty.channel.nio.NioEventLoop",
            "method":"processSelectedKeysOptimized",
            "line":724
         },
         {
            "class":"io.netty.channel.nio.NioEventLoop",
            "method":"processSelectedKeys",
            "line":650
         },
         {
            "class":"io.netty.channel.nio.NioEventLoop",
            "method":"run",
            "line":562
         },
         {
            "class":"io.netty.util.concurrent.SingleThreadEventExecutor$4",
            "method":"run",
            "line":997
         },
         {
            "class":"io.netty.util.internal.ThreadExecutorMap$2",
            "method":"run",
            "line":74
         },
         {
            "class":"io.netty.util.concurrent.FastThreadLocalRunnable",
            "method":"run",
            "line":30
         },
         {
            "class":"java.lang.Thread",
            "method":"run",
            "line":1583
         }
      ]
   }
}

Expected Behavior

Describe the expected behaviour.

Actual Behavior

Describe the current/actual behaviour.

Environment

  • Operating system:
  • OpenShift versions:
  • Project Versions:

Steps to reproduce

Describe all steps and pre-requirements which are required to be performed in order to reproduce this scenario. ( E.g 1. Action, 2. Action ... )

@zhechense zhechense changed the title MetricsFilter has NPE with Keycloak 25 MetricsFilter has IndexOutOfBoundsException with Keycloak 25 Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant