You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2026/09/22 09:06:54 UTC

Re: [PR] Java SDK: Honor TaskFlow arg bindings sent by the supervisor [airflow]

FrankYang0529 commented on code in PR #71188:
URL: https://github.com/apache/airflow/pull/71188#discussion_r4069961434


##########
java-sdk/README.md:
##########
@@ -590,7 +590,7 @@ prek hook regenerate it.
 
 <!-- BEGIN AUTO-GENERATED LANG-SDK COMPAT MATRIX -->
 
-*Min. Airflow version: 3.3 · supervisor schema: 2026-06-16*
+*Min. Airflow version: 3.3 · supervisor schema: 2026-10-30*

Review Comment:
   Do we need to update "Min. Airflow version" to 3.4? It looks like 3.3 doesn't have shcema 2026-10-30.



##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Bundle.kt:
##########
@@ -31,17 +31,72 @@ package org.apache.airflow.sdk
 class Bundle(
   dags: Iterable<DagDef>,
 ) {
-  internal val dags: Map<String, DagDef> = dags.associateByDagId()
-}
+  internal val dags = linkedMapOf<String, DagDef>()
+
+  /** Creates an empty bundle to [register] into. */
+  constructor() : this(emptyList())
 
-private fun Iterable<DagDef>.associateByDagId(): Map<String, DagDef> {
-  val dagMap = linkedMapOf<String, DagDef>()
-  for (dag in this) {
-    require(dagMap.putIfAbsent(dag.id, dag) == null) {
+  init {
+    dags.forEach { register(it) }
+  }
+
+  /**
+   * Registers a Dag.
+   *
+   * @return This bundle, for chaining.
+   * @throws IllegalArgumentException if another Dag shares its ID.
+   */
+  fun register(dag: DagDef): Bundle {
+    require(dags.putIfAbsent(dag.id, dag) == null) {
       "Dags in bundle have duplicate ID: ${dag.id}"
     }
+    return this
+  }
+
+  /**
+   * Registers every task handler a class holds, from the ids each
+   * [Builder.TaskHandler] names.
+   *
+   * @param handlerClass A class with [Builder.TaskHandler] methods.
+   * @return This bundle, for chaining.
+   * @throws IllegalArgumentException if the class has no generated
+   *    registrar, because annotation processing did not run over it.
+   */
+  fun register(handlerClass: Class<*>): Bundle {
+    val registrar =
+      try {
+        Class.forName("${handlerClass.name}Handlers", true, handlerClass.classLoader)

Review Comment:
   `register(Class)` and the processor derive the registrar name from two different things. This line uses `handlerClass.name`, so for a nested class it looks for `org.example.Outer$InnerHandlers`. At `BuilderProcessor.kt`, the processor names the registrar from `el.simpleName`, so the generated class is `org.example.InnerHandlers`. We may need to align this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org