Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running compose up fails when OSType is not reported #464

Open
NicoKandut opened this issue Nov 14, 2024 · 4 comments
Open

Running compose up fails when OSType is not reported #464

NicoKandut opened this issue Nov 14, 2024 · 4 comments

Comments

@NicoKandut
Copy link

Hey, I have a case where the plugin fails to extract the OSType from the info output which leads to a NPE in getDockerPlatform.

String getDockerPlatform() {
    String osType = getDockerInfo().collect { it.trim() }.find { it.startsWith('OSType:') }
    osType.empty ? System.getProperty("os.name") : osType.substring('OSType:'.length()).trim()
}

In this function osType can be null. Is it possible to improve the null safety here?

Stacktrace:

Caused by: java.lang.NullPointerException: Cannot get property 'empty' on null object
	at com.avast.gradle.dockercompose.DockerExecutor.getDockerPlatform(DockerExecutor.groovy:51)
	at com.avast.gradle.dockercompose.DockerExecutor_Decorated.getDockerPlatform(Unknown Source)
	at com.avast.gradle.dockercompose.DockerExecutor.getContainerPlatform(DockerExecutor.groovy:56)
	at com.avast.gradle.dockercompose.DockerExecutor$getContainerPlatform$0.callCurrent(Unknown Source)
	at com.avast.gradle.dockercompose.DockerExecutor.getContainerHost(DockerExecutor.groovy:122)
	at com.avast.gradle.dockercompose.DockerExecutor$getContainerHost.call(Unknown Source)
	at com.avast.gradle.dockercompose.tasks.ComposeUp.createContainerInfo(ComposeUp.groovy:248)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at com.avast.gradle.dockercompose.tasks.ComposeUp$_loadServicesInfo_closure15$_closure26.doCall$original(ComposeUp.groovy:242)
	at com.avast.gradle.dockercompose.tasks.ComposeUp$_loadServicesInfo_closure15$_closure26.doCall(ComposeUp.groovy)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at com.avast.gradle.dockercompose.tasks.ComposeUp$_loadServicesInfo_closure15.doCall$original(ComposeUp.groovy:242)
	at com.avast.gradle.dockercompose.tasks.ComposeUp$_loadServicesInfo_closure15.doCall(ComposeUp.groovy)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at com.avast.gradle.dockercompose.tasks.ComposeUp.loadServicesInfo(ComposeUp.groovy:242)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at com.avast.gradle.dockercompose.tasks.ComposeUp.up(ComposeUp.groovy:147)
@augi
Copy link
Member

augi commented Nov 14, 2024

Hi, thank you for the report. Sure, a PR to address this issue is likely to be merged ASAP 🙏

@NicoKandut
Copy link
Author

NicoKandut commented Nov 14, 2024

Thank you for the quick response. Are you accepting PRs from external people? Aka can I provide a PR or do you prefer to do it yourself?

@augi
Copy link
Member

augi commented Nov 14, 2024

Yep, definitely accept PRs from external contributors, and very appreciated 🙏

@NicoKandut
Copy link
Author

Cool. Sadly, I won't have time until Monday but I will submit it then.

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

No branches or pull requests

2 participants