[OpenNMS/opennms] 0b9b80: NMS-20111: Port BSFNotificationStrategy to JSR-223

Marshall Massengill via opennms-cvs <[email protected]> Fri, 31 Jul 2026 05:52:11 -0700
Newsgroups gmane.network.opennms.cvs
Message-ID <OpenNMS/opennms/push/refs/heads/mm/NMS-20111-smoke/[email protected]>
  Branch: refs/heads/mm/NMS-20111-smoke
  Home:   https://github.com/OpenNMS/opennms
  Commit: 0b9b80865770143abbf6c5015cda7b32f27ff33a
      https://github.com/OpenNMS/opennms/commit/0b9b80865770143abbf6c5015cda7b32f27ff33a
  Author: Marshall Massengill <[email protected]>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M opennms-services/pom.xml
    M opennms-services/src/main/java/org/opennms/netmgt/notifd/BSFNotificationStrategy.java
    M opennms-services/src/test/java/org/opennms/netmgt/notifd/BSFNotificationStrategyIT.java

  Log Message:
  -----------
  NMS-20111: Port BSFNotificationStrategy to JSR-223

Apache BSF is retired to the Apache Attic; the strategy now runs
scripts through javax.script. The class name, all 25 script variable
names, the results["status"]=="OK" contract, run-type exec/eval
semantics, and the 0/-1 return mapping are unchanged, so existing
notificationCommands.xml entries and scripts keep working. The engine
is chosen by lang-class (JSR-223 name) or the file extension, with
BSF's .gy alias mapped to Groovy; bsf-engine and file-extensions are
accepted but ignored with a warning.

Compiled scripts are cached per path+engine with lastModified
invalidation (Groovy leaks a class per compilation, same rationale as
provisiond's JSR223ScriptCache); the compile attempt catches Throwable
because BeanShell declares Compilable but its compile() throws
Error("unimplemented"), in which case scripts are evaluated from
source on a fresh per-invocation engine. Bindings are built per
invocation, which drops the old static synchronized serialization of
every scripted notification and the declare/undeclare dance.

The IT grows from one to nine cases (eval, Groovy, .gy, lang-class
resolution, missing file, non-OK status, invalid run-type, deprecated
switches) and uses the database populator's actual node id: node ids
are sequence-assigned, so the hardcoded 1 only worked while the class
had a single test.


  Commit: 0bf8f9094b1db05d128ad146f5abdf53a7b6ad46
      https://github.com/OpenNMS/opennms/commit/0bf8f9094b1db05d128ad146f5abdf53a7b6ad46
  Author: Marshall Massengill <[email protected]>
  Date:   2026-07-31 (Fri, 31 Jul 2026)

  Changed paths:
    M docs/modules/operation/nav.adoc
    A docs/modules/operation/pages/deep-dive/notifications/strategies/scripting.adoc
    M docs/modules/releasenotes/pages/changelog.adoc
    M docs/modules/releasenotes/pages/whatsnew.adoc

  Log Message:
  -----------
  NMS-20111: Document the scripted notification strategy

The strategy was never documented; adds a Scripted Notifications page
(parameters, script variables, the results.status success contract,
BSF migration notes) to the notification strategies section, plus the
release-note entries for the JSR-223 port.


  Commit: a9d82e83e005dfc471847e40ca7a9af6d67ea145
      https://github.com/OpenNMS/opennms/commit/a9d82e83e005dfc471847e40ca7a9af6d67ea145
  Author: Marshall Massengill <[email protected]>
  Date:   2026-07-31 (Fri, 31 Jul 2026)

  Changed paths:
    M docs/modules/operation/pages/deep-dive/notifications/bonus-strategies.adoc
    M docs/modules/operation/pages/deep-dive/notifications/strategies/scripting.adoc
    M docs/modules/releasenotes/pages/whatsnew.adoc
    M opennms-services/pom.xml
    M opennms-services/src/main/java/org/opennms/netmgt/notifd/BSFNotificationStrategy.java
    M opennms-services/src/test/java/org/opennms/netmgt/notifd/BSFNotificationStrategyIT.java

  Log Message:
  -----------
  NMS-20111: Apply adversarial-review findings

- BeanShell scripts see null variables again: bsh's JSR-223 engine
  treats a null binding as an undefined variable, breaking scripts
  that test node fields against null (worked under BSF). The
  BeanShell path now drives bsh.Interpreter directly, as BSF did;
  Interpreter.set defines nulls properly. Reflective, since bsh is a
  runtime-scope dependency.
- The command's <substitution> element is honored when the argument
  value is empty, so the strategy's own switches (file-name,
  lang-class, run-type) can be configured in notificationCommands.xml
  the way the docs show; notifd passes empty values for switches
  without a notification parameter, which previously made the
  documented setup - and the bsf-engine deprecation warning -
  unreachable.
- Compile failures no longer latch the script-cache entry when the
  script itself is at fault: a fixed script compiles again. Only
  engines that cannot compile (BeanShell throws Error) latch. Cache
  keys derive from lang-class/extension so cache hits build no
  throwaway engine, and mtime comparison uses != so restored-older
  files also invalidate.
- Groovy engines come from a runtime-scope groovy-dependencies entry
  instead of relying on provision-persistence keeping groovy on the
  classpath; a GLOBAL_SCOPE bindings object avoids a bsh NPE path.
- IT covers the review gaps: null bindings, substitution-shaped
  config, cache reuse + mtime invalidation, missing file-name.
- Docs: substitution vs notification-parameter configuration spelled
  out, microblog_username listed as deprecated, release note no
  longer overstates engine-state isolation and mentions strict UTF-8.


Compare: https://github.com/OpenNMS/opennms/compare/0b9b80865770%5E...a9d82e83e005

To unsubscribe from these emails, change your notification settings at https://github.com/OpenNMS/opennms/settings/notifications


_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/wiki/index.php?page=MailingListFaq
opennms-cvs mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-cvs