{"record":{"id":"9f5ebd5ab723f0ee","repo":"apache/rocketmq","slug":"mq-is-null","errorCode":null,"errorMessage":"mq is null","messagePattern":"mq is null","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java","lineNumber":1047,"sourceCode":"    }\n\n    private PullResult pull(MessageQueue mq, SubscriptionData subscriptionData, long offset, int maxNums)\n        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n        return pull(mq, subscriptionData, offset, maxNums, this.defaultLitePullConsumer.getConsumerPullTimeoutMillis());\n    }\n\n    private PullResult pull(MessageQueue mq, SubscriptionData subscriptionData, long offset, int maxNums, long timeout)\n        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n        return this.pullSyncImpl(mq, subscriptionData, offset, maxNums, true, timeout);\n    }\n\n    private PullResult pullSyncImpl(MessageQueue mq, SubscriptionData subscriptionData, long offset, int maxNums,\n        boolean block,\n        long timeout)\n        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n\n        if (null == mq) {\n            throw new MQClientException(\"mq is null\", null);\n        }\n\n        if (offset < 0) {\n            throw new MQClientException(\"offset < 0\", null);\n        }\n\n        if (maxNums <= 0) {\n            throw new MQClientException(\"maxNums <= 0\", null);\n        }\n\n        int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false, true);\n\n        long timeoutMillis = block ? this.defaultLitePullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;\n\n        boolean isTagType = ExpressionType.isTagType(subscriptionData.getExpressionType());\n        PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(\n            mq,\n            subscriptionData.getSubString(),","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java#L1029-L1065","documentation":"The internal pull path DefaultLitePullConsumerImpl.pullSyncImpl rejects a null MessageQueue with MQClientException(\"mq is null\") before building the pull request. It surfaces through the public pull(MessageQueue, ...) APIs of DefaultLitePullConsumer when the caller passes a null queue (typically one that was never found in a lookup).","triggerScenarios":"consumer.pull(null, subExpression, offset, maxNums); passing a queue variable whose lookup (e.g. map.get) returned null.","commonSituations":"Iterating a queue collection that contains nulls; a queue lookup keyed by broker name that misses.","solutions":["Null-check the MessageQueue before calling pull","Filter nulls out of queue collections: queues.removeIf(Objects::isNull)","Log the lookup key when a queue is not found instead of propagating null"],"exampleFix":"// before\nMessageQueue q = queueMap.get(brokerName);\nPullResult pr = consumer.pull(q, \"*\", 0, 1, 3000);\n\n// after\nMessageQueue q = queueMap.get(brokerName);\nif (q == null) throw new IllegalArgumentException(\"no queue for broker \" + brokerName);\nPullResult pr = consumer.pull(q, \"*\", 0, 1, 3000);","handlingStrategy":"validation","validationCode":"if (mq == null) throw new IllegalArgumentException(\"MessageQueue not resolved\");\nPullResult r = consumer.pull(mq, expr, offset, maxNums, timeout);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter nulls from queue collections before iterating","Fail lookups loudly instead of propagating null queues into pull"],"tags":["rocketmq","consumer","pull","null-check"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}