[OpenNMS/opennms] 65b4c4: NMS-20111: Port BSFNotificationStrategy to JSR-223

Marshall Massengill via opennms-cvs <[email protected]>
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: 65b4c475048093fbdae69bc24ece99452d0b190b
      https://github.com/OpenNMS/opennms/commit/65b4c475048093fbdae69bc24ece99452d0b190b
  Author: Marshall Massengill <[email protected]>
  Date:   2026-08-05 (Wed, 05 Aug 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: e7341859eebab19f20836f7bea5aa837e67a7707
      https://github.com/OpenNMS/opennms/commit/e7341859eebab19f20836f7bea5aa837e67a7707
  Author: Marshall Massengill <[email protected]>
  Date:   2026-08-05 (Wed, 05 Aug 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: 4bb6e9cf63684bce78c33d1b83e4e6a32e7b0358
      https://github.com/OpenNMS/opennms/commit/4bb6e9cf63684bce78c33d1b83e4e6a32e7b0358
  Author: Marshall Massengill <[email protected]>
  Date:   2026-08-05 (Wed, 05 Aug 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.


  Commit: 1048060c867790d5614421d6452f5c529982f1e9
      https://github.com/OpenNMS/opennms/commit/1048060c867790d5614421d6452f5c529982f1e9
  Author: Marshall Massengill <[email protected]>
  Date:   2026-08-05 (Wed, 05 Aug 2026)

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

  Log Message:
  -----------
  NMS-20111: Trim the whats-new entry to a single line

Review feedback on #8718: whats-new items should stay within two lines so the page
is quick to scan, with the detail in the deep-dive documentation.

The entry now states the change and links to Scripted Notifications. Everything it
listed was already covered there, apart from the UTF-8 caveat, which moves into that
page's notes on migrating BSF-era scripts.


Compare: https://github.com/OpenNMS/opennms/compare/a700f93b2f81...1048060c8677

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.