Skip to content

Commit a3b0f90

Browse files
authored
fix: Restrict the condition for Gradle JVM string (#706)
* fix: Restrict the condition for Gradle JVM string to make sure it doesn't parse the wrong one * Fix format
1 parent 5c8dae8 commit a3b0f90

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

aws_lambda_builders/workflows/java_gradle/gradle_validator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@ def _get_jvm_string(self, gradle_path):
8383

8484
for line in stdout.splitlines():
8585
l_dec = decode(line)
86-
if "JVM" in l_dec:
86+
if l_dec.startswith("JVM") or l_dec.startswith("Launcher JVM"):
8787
return l_dec

tests/unit/workflows/java_gradle/test_gradle_validator.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ def test_emits_warning_when_gradle_excutable_fails(self):
6969
validator.validate(runtime_path=self.runtime_path)
7070
self.mock_log.warning.assert_called_with(GradleValidator.VERSION_STRING_WARNING, self.runtime_path)
7171

72-
def test_emits_warning_when_version_string_not_found(self):
73-
version_string = "The Java Version: 9.0.0".encode()
72+
@parameterized.expand(
73+
[
74+
"The Java Version: 9.0.0",
75+
"Daemon JVM: /Library/Java/JavaVirtualMachines/amazon-corretto-21.jdk/Contents/Home (no JDK specified, using current Java home)",
76+
]
77+
)
78+
def test_emits_warning_when_version_string_not_found(self, path):
79+
version_string = path.encode()
7480
self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)]
7581
validator = GradleValidator(
7682
runtime=self.runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log

0 commit comments

Comments
 (0)