datastax / pulsar-jms

DataStax Starlight for JMS, a JMS API for Apache Pulsar ®
Apache License 2.0
48 stars 21 forks source link

NullPointerException while trying close consumer #4

Closed k-focaloid closed 2 years ago

k-focaloid commented 3 years ago

I am getting random NullPointerException during runtime when i try to close the consumer. The issue happens when request rate is high, i used Jmeter to test the load. try-with causes response to be 500. i am using JMSContext.

@RestController
public class DummyController {

    @Autowired
    JMSContext context; //Bean is created and injected else where

    @GetMapping(value = "/test")
    String test() {
        Destination destination = context.createQueue("persistent://id-service/my.name.space/Java.AMQP.Test.Queue");
        TemporaryQueue replyToDestination = context.createTemporaryQueue();
        context.createProducer().setJMSReplyTo(replyToDestination).send(destination, "text 123");

        //Other Processing

        //Consumer for the result
        JMSConsumer consumer = context.createConsumer(replyToDestination);
        String message = consumer.receiveBody(String.class) + "<br>Producer Reply : " + replyToDestination;
        try {
            consumer.close();
        } catch (JMSRuntimeException ex) {
            ex.printStackTrace();
        }
        return message;
    }
}
javax.jms.JMSRuntimeException: java.lang.NullPointerException
        at com.datastax.oss.pulsar.jms.Utils.throwAsRuntimeException(Utils.java:282)
        at com.datastax.oss.pulsar.jms.Utils.runtimeException(Utils.java:231)
        at com.datastax.oss.pulsar.jms.PulsarMessageConsumer$1.close(PulsarMessageConsumer.java:530)
        at examples.controllers.DummyController.test(DummyController.java:33)
        at jdk.internal.reflect.GeneratedMethodAccessor94.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.jms.JMSException: java.lang.NullPointerException
        at com.datastax.oss.pulsar.jms.Utils.handleException(Utils.java:63)
        at com.datastax.oss.pulsar.jms.PulsarMessageConsumer.lambda$close$3(PulsarMessageConsumer.java:443)
        at com.datastax.oss.pulsar.jms.PulsarSession.executeCriticalOperation(PulsarSession.java:1621)
        at com.datastax.oss.pulsar.jms.PulsarMessageConsumer.close(PulsarMessageConsumer.java:436)
        at com.datastax.oss.pulsar.jms.PulsarMessageConsumer$1.lambda$close$6(PulsarMessageConsumer.java:530)
        at com.datastax.oss.pulsar.jms.Utils.runtimeException(Utils.java:226)
        ... 51 more
Caused by: java.lang.NullPointerException

Caused by: java.lang.NullPointerException at com.datastax.oss.pulsar.jms.PulsarSession.removeConsumer(PulsarSession.java:1555) at com.datastax.oss.pulsar.jms.PulsarMessageConsumer.lambda$close$3(PulsarMessageConsumer.java:440) ... 55 more

May be: PulsarSession.java:1555

  PulsarMessage message = it.next();
        if (message.isReceivedFromConsumer(consumer)) {

is coming as null ?

eolivelli commented 2 years ago

@k-focaloid which version are you using?

Probably your problem has been addressed with some of the latest releases as we have refactored a little bit the Consumer closing code.

Can you please try with the latest release ?

eolivelli commented 2 years ago

@k-focaloid did you manage to fix this by upgrading ? can we close this ticket ?