This is an automated email from the ASF dual-hosted git repository.

yhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 576c508245e Fix #[35617] Windows compatibility for YAML 
JavaJarProvider (#35803)
576c508245e is described below

commit 576c508245eb0289b40b3f39fdf65486e969b7c1
Author: Lanny Boarts <[email protected]>
AuthorDate: Wed Aug 13 11:25:39 2025 +0800

    Fix #[35617] Windows compatibility for YAML JavaJarProvider (#35803)
---
 CHANGES.md                                    |  3 +--
 sdks/python/apache_beam/yaml/yaml_provider.py | 21 ++++++---------------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index c754a4fe658..ac12203b3d6 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -93,10 +93,9 @@
 
 ## Bugfixes
 
-* Fixed X (Java/Python) ([#X](https://github.com/apache/beam/issues/X)).
+* (Python) Fixed Java YAML provider fails on Windows 
([#35617](https://github.com/apache/beam/issues/35617)).
 * Fixed BigQueryIO creating temporary datasets in wrong project when 
temp_dataset is specified with a different project than the pipeline project. 
For some jobs, temporary datasets will now be created in the correct project 
(Python) ([#35813](https://github.com/apache/beam/issues/35813)).
 
-
 ## Known Issues
 
 * ([#X](https://github.com/apache/beam/issues/X)).
diff --git a/sdks/python/apache_beam/yaml/yaml_provider.py 
b/sdks/python/apache_beam/yaml/yaml_provider.py
index 9ce9b8e2180..34c14c8ee8e 100755
--- a/sdks/python/apache_beam/yaml/yaml_provider.py
+++ b/sdks/python/apache_beam/yaml/yaml_provider.py
@@ -384,22 +384,13 @@ class ExternalJavaProvider(ExternalProvider):
     self._classpath = classpath
 
   def available(self):
-    # pylint: disable=subprocess-run-check
-    trial = subprocess.run(['which', subprocess_server.JavaHelper.get_java()],
-                           capture_output=True)
-    if trial.returncode == 0:
+    # Directly use shutil.which to find the Java executable cross-platform
+    java_path = shutil.which(subprocess_server.JavaHelper.get_java())
+    if java_path:
       return True
-    else:
-
-      def try_decode(bs):
-        try:
-          return bs.decode()
-        except UnicodeError:
-          return bs
-
-      return NotAvailableWithReason(
-          f'Unable to locate java executable: '
-          f'{try_decode(trial.stdout)}{try_decode(trial.stderr)}')
+    # Return error message when not found
+    return NotAvailableWithReason(
+        'Unable to locate java executable: java not found in PATH or 
JAVA_HOME')
 
   def cache_artifacts(self):
     return [self._jar_provider()]

Reply via email to