Skip to content

[Build] Allow the legacy SecurityManager for FlinkClient#submit on JDK 18+ - #4487

Open
88fantasy wants to merge 1 commit into
apache:devfrom
88fantasy:fix/flink-client-security-manager-jdk17
Open

[Build] Allow the legacy SecurityManager for FlinkClient#submit on JDK 18+#4487
88fantasy wants to merge 1 commit into
apache:devfrom
88fantasy:fix/flink-client-security-manager-jdk17

Conversation

@88fantasy

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request

Issue Number: close #4482

Fixes every POST /flink/app/start failing silently on JDK 18+ with UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release, thrown from FlinkClient#submit()'s System.setSecurityManager(new ExitSecurityManager()) call.

Brief change log

  • Add -Djava.security.manager=allow to jvm_opts.sh, next to the existing JDK 9+/17+ compatibility flags (--add-opens ...) already there for ClassLoaderUtils. This re-enables dynamically setting a SecurityManager at runtime, which JEP 411 disabled by default starting Java 18.

Verifying this change

Manually verified against a real Flink 2.2.1 standalone cluster, JDK 21 console:

This is a plain JVM system property — harmless and effectively a no-op on JDK 8-17 (SecurityManager is either unaffected or already dynamically settable there), required on JDK 18+.

Does this pull request potentially affect one of the following parts

  • Dependencies (does it add or upgrade a dependency): no
  • Anything that affects deployment: yes — adds one JVM flag to the console's own startup options (jvm_opts.sh), same category as the existing --add-opens flags
  • The persistence of application state: no
  • The direction of network connections: no
  • Anything that affects any api: no

…n JDK 18+

FlinkClient#submit() installs a custom ExitSecurityManager via
System.setSecurityManager() before invoking the Flink CLI in-process, purely
to intercept System.exit() calls the CLI makes on completion (turning them
into a catchable SecurityException instead of killing the whole console JVM).

JEP 411 deprecated the Security Manager in Java 17 and, starting Java 18,
System.setSecurityManager() throws UnsupportedOperationException unless the
java.security.manager system property is explicitly set to "allow" (or a
manager class name) at JVM startup -- it can no longer be set dynamically
without that flag. The console ships with a JDK 21 target, so every attempt
to start a Flink application fails with:

  java.lang.UnsupportedOperationException: The Security Manager is
  deprecated and will be removed in a future release
      at java.base/java.lang.System.setSecurityManager(System.java:431)
      at org.apache.streampark.flink.client.FlinkClient.submit(FlinkClient.java:63)

This exception is wrapped in a CompletionException and only persisted to the
t_flink_app_log table (via ApplicationLog / POST /flink/app/opt_log) -- it
never reaches the console's own log files, so the application just silently
flips to FAILED a few seconds after every start attempt with no visible
error anywhere in logs/.

Add -Djava.security.manager=allow next to the existing JDK 9+/17+
compatibility flags in jvm_opts.sh, following the same pattern as the
--add-opens flags already there for ClassLoaderUtils. This is a plain system
property: harmless on JDK 8-17 (ignored/already-default there), required on
JDK 18+.

Reproduced end to end against a real Flink 2.2.1 standalone cluster: without
this flag, POST /flink/app/start is accepted (HTTP 200) but the application
flips to FAILED within ~5s with the exception above recorded only in
t_flink_app_log, never in logs/error.*.log or logs/streampark.out.
@sonarqubecloud

Copy link
Copy Markdown

@wolfboys wolfboys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] FlinkClient#submit fails with UnsupportedOperationException on JDK 18+ (Security Manager)

2 participants