René's URL Explorer Experiment


Title: NullPointerException in HandlerManager when enabling Python addon on second instrument · Issue #36 · BookmapAPI/python-api · GitHub

Open Graph Title: NullPointerException in HandlerManager when enabling Python addon on second instrument · Issue #36 · BookmapAPI/python-api

X Title: NullPointerException in HandlerManager when enabling Python addon on second instrument · Issue #36 · BookmapAPI/python-api

Description: NullPointerException in HandlerManager when enabling Python addon on second instrument Environment Bookmap version: 7.6.0 build 30 Bookmap embedded Python: 3.9 (miniforge bm39 env) OS: Windows 11 (WSL Ubuntu-24.04 used to host the addon ...

Open Graph Description: NullPointerException in HandlerManager when enabling Python addon on second instrument Environment Bookmap version: 7.6.0 build 30 Bookmap embedded Python: 3.9 (miniforge bm39 env) OS: Windows 11 (...

X Description: NullPointerException in HandlerManager when enabling Python addon on second instrument Environment Bookmap version: 7.6.0 build 30 Bookmap embedded Python: 3.9 (miniforge bm39 env) OS: Windows 11 (...

Opengraph URL: https://github.com/BookmapAPI/python-api/issues/36

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NullPointerException in HandlerManager when enabling Python addon on second instrument","articleBody":"# NullPointerException in HandlerManager when enabling Python addon on second instrument\n\n## Environment\n\n- **Bookmap version:** 7.6.0 build 30\n- **Bookmap embedded Python:** 3.9 (miniforge `bm39` env)\n- **OS:** Windows 11 (WSL Ubuntu-24.04 used to host the addon source)\n- **Data provider:** Rithmic Paper\n- **Instruments tested:** NQM6.CME@RITHMIC, ESM6.CME@RITHMIC\n- **Strategy type:** Simplified L1 Python addon\n- **Loader:** `runpy.run_path(...)` from Bookmap's Python editor\n\n## Summary\n\nA Python addon that subscribes to multiple instruments via `INSTRUMENT_ALIASES`\ncrashes Bookmap with `java.lang.NullPointerException` in\n`HandlerManager.handle()` immediately after the `subscribe` handler\nfires for the second instrument. The crash happens regardless of which\ninstrument is enabled first (NQ then ES, or ES then NQ), and regardless\nof the Python-side state. Single-instrument operation works perfectly.\n\n## Reproduction steps\n\n1. Create a Python addon (full code below) that calls `bm.create_addon`,\n   adds trades + depth + on_interval handlers, and starts with\n   `bm.start_addon(addon, subscribe_handler, unsubscribe_handler)`.\n2. Load the script in Bookmap via the Python editor:\n   ```python\n   import runpy\n   runpy.run_path(r'\u003cpath_to_script>', run_name='__main__')\n   ```\n3. Enable the addon for the **first** instrument (e.g. NQM6.CME@RITHMIC).\n   Observe: subscribe handler fires correctly, addon starts processing.\n   `snapshot.json` is written every 100ms with valid data. ✅\n4. Enable the addon for the **second** instrument (e.g. ESM6.CME@RITHMIC),\n   without disabling the first. Observe:\n   - Python's `subscribe` handler IS called for the second instrument\n   - `STATE` dict reaches size 2\n   - **~2ms later**, Bookmap throws `NullPointerException` and unloads\n     the addon. ❌\n\nThe same crash happens in the reverse order (ES first, then NQ).\n\n## Stack trace\n\n```\njava.lang.NullPointerException: Cannot invoke\n\"com.bookmap.api.rpc.server.handlers.HandlerManager.handle(com.bookmap.api.rpc.server.data.utils.AbstractEvent)\"\nbecause \"this.handlerManager\" is null\n\tat com.bookmap.api.rpc.server.EventLoop.lambda$new$0(EventLoop.java:27)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n```\n\nAfter the NPE, Bookmap unloads the addon (`Unloading strategy/indicator\n... bm_producer.jar`), the Python `unsubscribe_instrument` handler is\ncalled for the first instrument, and the addon process exits. Settings\nget persisted with `disabling for ESM6.CME@RITHMIC` flags so the\n`Strategy settings were saved before it was loaded last time` message\nappears on the next load.\n\n## Relevant Bookmap log excerpt\n\n```\n20260428 22:11:05.581 (AWT-EventQueue-1) Stratgies dialog: com.bookmap.api.rpc.server.addon.bm_producer true\n20260428 22:11:05.581 (AWT-EventQueue-1) Enabled for NQM6.CME@RITHMIC true - started (Simplified L1)\n20260428 22:11:05.613 (AWT-EventQueue-1) BrApi(...): Add-on \"bm_producer\" - Became available for broadcasts as a consumer.\n20260428 22:11:05.614 [PYTHON-CLIENT] [bm_producer] subscribe alias=NQM6.CME@RITHMIC ... pips=0.25 size_mult=1.0\n20260428 22:11:05.614 [PYTHON-CLIENT] [bm_producer]   registered short=NQ trades+depth subscribed; STATE size=2\n20260428 22:11:05.614 [RPC-SERVER] Received finish initialization message for NQM6.CME@RITHMIC\n20260428 22:11:05.616 (AWT-EventQueue-1) Enabled for NQM6.CME@RITHMIC true - complete (Simplified L1)\n20260428 22:11:05.618 ERROR: (Global Exception Handler) Intercepted exception from strategy\njava.lang.NullPointerException: Cannot invoke \"com.bookmap.api.rpc.server.handlers.HandlerManager.handle(...)\" because \"this.handlerManager\" is null\n    at com.bookmap.api.rpc.server.EventLoop.lambda$new$0(EventLoop.java:27)\n    ...\n20260428 22:11:05.624 (AWT-EventQueue-1) Unloading strategy/indicator C:\\Bookmap\\Python\\build\\bm_producer.jar com.bookmap.api.rpc.server.addon.bm_producer\n```\n\n(In this excerpt, ES had been enabled first at 22:09:53 and worked\ncorrectly for ~72 seconds. NQ was enabled at 22:11:05; the NPE\noccurred at 22:11:05.618 — about 2ms after the Python-side `subscribe`\nhandler completed for NQ.)\n\n## Minimal repro script\n\n```python\n\"\"\"Minimal reproduction of NPE when enabling addon on second instrument.\"\"\"\nimport bookmap as bm\nimport threading\nfrom datetime import datetime, timezone\n\ndef stamp():\n    return datetime.now(timezone.utc).isoformat(timespec=\"microseconds\")\n\ndef log(msg):\n    print(\"[repro] [\" + stamp() + \"] \" + msg, flush=True)\n\nSTATE = {}\n\ndef handle_subscribe_instrument(addon, alias, full_name, is_crypto, pips,\n                                size_multiplier, instrument_multiplier,\n                                supported_features):\n    log(\"subscribe alias=\" + str(alias) + \" (STATE size before=\" + str(len(STATE)) + \")\")\n    STATE[alias] = {\"order_book\": bm.create_order_book()}\n    bm.subscribe_to_trades(addon, alias, len(STATE))\n    bm.subscribe_to_depth(addon, alias, len(STATE) + 100)\n    log(\"  subscribed; STATE size=\" + str(len(STATE)))\n\ndef handle_unsubscribe_instrument(addon, alias):\n    log(\"unsubscribe alias=\" + str(alias))\n    STATE.pop(alias, None)\n\ndef handle_trades(addon, alias, price, size, is_otc, is_bid,\n                  is_execution_start, is_execution_end,\n                  aggressor_order_id, passive_order_id):\n    pass  # no-op\n\ndef handle_depth(addon, alias, is_bid, price, size):\n    state = STATE.get(alias)\n    if state is not None:\n        bm.on_depth(state[\"order_book\"], is_bid, price, size)\n\ndef on_interval(addon, alias):\n    pass  # no-op\n\nif __name__ == \"__main__\":\n    log(\"STARTUP, thread=\" + threading.current_thread().name)\n    addon = bm.create_addon()\n    bm.add_trades_handler(addon, handle_trades)\n    bm.add_depth_handler(addon, handle_depth)\n    bm.add_on_interval_handler(addon, on_interval)\n    bm.start_addon(addon, handle_subscribe_instrument, handle_unsubscribe_instrument)\n    log(\"Addon started, blocking...\")\n    bm.wait_until_addon_is_turned_off(addon)\n    log(\"Addon stopped.\")\n```\n\nTo reproduce:\n1. Save as `repro.py`.\n2. Load in Bookmap via `runpy.run_path(r'\u003cpath>', run_name='__main__')`.\n3. Enable for any single instrument — works fine.\n4. Enable for a second instrument (without disabling the first) — NPE.\n\n## What I expected\n\nPer the official `start_addon` documentation:\n> `handle_subscribe_instrument` is a function that you should define.\n> It will be called **each time you enable the addon in Bookmap for a\n> certain instrument**.\n\nThis wording suggests one Python addon should handle multiple\ninstruments by receiving multiple `subscribe` calls (one per\ninstrument). The official examples (`mbo_test.py`, `cvd_addon.py`,\n`liquidity_tracker.py`, `simple_market_maker.py`) all use this pattern\nwith `alias_to_*` dicts, implying multi-instrument is the intended\ndesign.\n\n## What actually happens\n\nThe `subscribe` handler fires correctly for the second instrument, but\nBookmap's internal `EventLoop` then tries to dispatch an event to a\n`HandlerManager` that is `null`. This suggests the second-instrument\ninitialization path has a race condition or missing initialization on\nthe Java side.\n\n## Workaround currently in use\n\nI've added a guard in my Python addon that refuses any `subscribe` call\nbeyond the first. This restricts the addon to one instrument per\nsession. The user must disable the addon entirely before switching to\na different instrument. This works but defeats the whole point of\nmulti-instrument addons.\n\n```python\ndef handle_subscribe_instrument(addon, alias, ...):\n    if len(STATE) >= 1:\n        log(\"REFUSED: already subscribed to \" + str(list(STATE.keys())[0]))\n        return\n    # ... normal subscribe path ...\n```\n\n## Questions for the team\n\n1. Is there a known issue with multi-instrument Simplified L1 Python\n   addons in Bookmap 7.6.0?\n2. Should the Python API support multi-instrument in the same addon,\n   or is it expected behavior that each instrument requires a separate\n   addon load?\n3. If multi-instrument is supported, is there an initialization order\n   or method I'm missing in the bootstrap?\n4. If NOT supported, what's the recommended pattern for an addon that\n   needs to read data from multiple instruments simultaneously (e.g.\n   to compute cross-instrument correlations)?\n\nHappy to provide more logs, test other configurations, or run a debug\nbuild if helpful.\n\nThanks!\n","author":{"url":"https://github.com/michaelalvarezm","@type":"Person","name":"michaelalvarezm"},"datePublished":"2026-04-28T22:42:27Z","url":"https://github.com/BookmapAPI/python-api/issues/36"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:852f7cd0-c89b-0544-d9d5-9f6ce3f8cd5b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE358:27A9B8:1A48308:228AA18:6B040B48
html-safe-nonced13b394cc6d9a292c190e86adf8eb372136e43d014446bc7de96833e1522473b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzU4OjI3QTlCODoxQTQ4MzA4OjIyOEFBMTg6NkIwNDBCNDgiLCJ2aXNpdG9yX2lkIjoiMzc0MzE5OTAyOTczNjI0NjA4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3400be5dadb6f6a69f97ef433d71d4732797337d95577af1cbcbbbb012eaaa39
hovercard-subject-tagissue:4346698475
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/BookmapAPI/python-api/36/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d816c9fe14e90b99455e1b091e86e6f7966e7c8c09f46acc09df7b65586639f7/BookmapAPI/python-api/issues/36
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d816c9fe14e90b99455e1b091e86e6f7966e7c8c09f46acc09df7b65586639f7/BookmapAPI/python-api/issues/36
og:image:altNullPointerException in HandlerManager when enabling Python addon on second instrument Environment Bookmap version: 7.6.0 build 30 Bookmap embedded Python: 3.9 (miniforge bm39 env) OS: Windows 11 (...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemichaelalvarezm
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/BookmapAPI/python-api git https://github.com/BookmapAPI/python-api.git
octolytics-dimension-user_id25076219
octolytics-dimension-user_loginBookmapAPI
octolytics-dimension-repository_id536529076
octolytics-dimension-repository_nwoBookmapAPI/python-api
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id536529076
octolytics-dimension-repository_network_root_nwoBookmapAPI/python-api
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/BookmapAPI/python-api/issues/36#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FBookmapAPI%2Fpython-api%2Fissues%2F36
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FBookmapAPI%2Fpython-api%2Fissues%2F36
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=BookmapAPI%2Fpython-api
Reloadhttps://github.com/BookmapAPI/python-api/issues/36
Reloadhttps://github.com/BookmapAPI/python-api/issues/36
Reloadhttps://github.com/BookmapAPI/python-api/issues/36
BookmapAPIhttps://github.com/BookmapAPI
python-apihttps://github.com/BookmapAPI/python-api
Codehttps://github.com/BookmapAPI/python-api
Issues10 (10)https://github.com/BookmapAPI/python-api/issues
Pull requests1 (1)https://github.com/BookmapAPI/python-api/pulls
Actionshttps://github.com/BookmapAPI/python-api/actions
Projectshttps://github.com/BookmapAPI/python-api/projects
Security and qualityhttps://github.com/BookmapAPI/python-api/security
Insightshttps://github.com/BookmapAPI/python-api/insights
https://github.com/BookmapAPI/python-api
New issuehttps://github.com/login?return_to=https://github.com/BookmapAPI/python-api/issues/36
New issuehttps://github.com/login?return_to=https://github.com/BookmapAPI/python-api/issues/36
NullPointerException in HandlerManager when enabling Python addon on second instrumenthttps://github.com/BookmapAPI/python-api/issues/36#top
https://github.com/michaelalvarezm
michaelalvarezmhttps://github.com/michaelalvarezm
on Apr 28, 2026https://github.com/BookmapAPI/python-api/issues/36#issue-4346698475
Sign up for freehttps://github.com/signup?return_to=https://github.com/BookmapAPI/python-api/issues/36
Sign in to commenthttps://github.com/login?return_to=https://github.com/BookmapAPI/python-api/issues/36
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.