Skip to content

Commit 7d96ee1

Browse files
authored
Java SDK docs: JUL setup(), pin java_executable, config-reload note (#68938)
1 parent 79e9628 commit 7d96ee1

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

  • airflow-core/docs/authoring-and-scheduling/language-sdks

‎airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,15 @@ Add the artifact:
340340
341341
implementation("org.apache.airflow:airflow-sdk-jul:${version}")
342342
343-
and call ``AirflowJulHandler.install()`` on startup to attach the handler to the
344-
JUL root logger before any task runs:
343+
and call ``AirflowJulHandler.setup()`` on startup, before any task runs. It clears the JUL root
344+
logger's existing handlers (including the default ``ConsoleHandler``, whose stderr output Airflow
345+
would otherwise capture as ``task.stderr`` at ERROR level, duplicating each record and mislabeling
346+
its level) and installs ``AirflowJulHandler`` in their place:
345347

346348
.. code-block:: java
347349
348350
public static void main(String[] args) {
349-
AirflowJulHandler.install();
351+
AirflowJulHandler.setup();
350352
Server.create(args).serve(new MyBundle());
351353
}
352354
@@ -669,6 +671,40 @@ All ``kwargs`` in the ``coordinators`` config entry are passed to the
669671
- Seconds to wait for the JVM subprocess to connect after launch. Increase this if your
670672
JVM startup is slow (e.g. on constrained hardware or with a large classpath).
671673

674+
.. note::
675+
676+
The ``[sdk]`` configuration is read at startup, so changes to ``coordinators`` or
677+
``queue_to_coordinator`` (for example adding ``jvm_args``) only take effect after you restart the
678+
scheduler (or ``airflow standalone``). A rebuilt bundle JAR, by contrast, is picked up on the next
679+
task launch without a restart, because a fresh JVM is spawned per task instance.
680+
681+
.. _java-sdk/java-executable:
682+
683+
Pinning the Java executable
684+
---------------------------
685+
686+
As a general recommendation, set ``java_executable`` to an absolute path rather than relying on
687+
``java`` resolving from ``$PATH``. This pins tasks to a known JDK, which matters most in production or
688+
corporate environments where the Airflow admin may not control the system-wide ``java`` (the same
689+
reasoning behind pinning a Python version).
690+
691+
For example, if you install the JDK with Homebrew on macOS, its ``java`` is not on ``$PATH``, so
692+
point ``java_executable`` at it explicitly:
693+
694+
.. code-block:: ini
695+
696+
[sdk]
697+
coordinators = {
698+
"java-jdk17": {
699+
"classpath": "airflow.sdk.coordinators.java.JavaCoordinator",
700+
"kwargs": {
701+
"jars_root": ["/opt/airflow/jars"],
702+
"java_executable": "/opt/homebrew/opt/openjdk@17/bin/java"
703+
}
704+
}
705+
}
706+
queue_to_coordinator = {"java": "java-jdk17"}
707+
672708
.. _java-sdk/limitations:
673709

674710
Limitations

0 commit comments

Comments
 (0)