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

NPE during Preconditions validation #2702

Closed
vgalloy opened this issue Aug 14, 2020 · 3 comments · Fixed by #2704
Closed

NPE during Preconditions validation #2702

vgalloy opened this issue Aug 14, 2020 · 3 comments · Fixed by #2704
Assignees
Milestone

Comments

@vgalloy
Copy link

vgalloy commented Aug 14, 2020

Environment:

  • Jib version: 2.5.0
  • Build tool: gradle 6.6
  • OS: Ubuntu 20.04.1 LTS
  • Java: openjdk version "14" 2020-03-17

Description of the issue:
ImmutableCollections#contains(Object) throw a NullPointerException if the argument is null. Checking if collection contains null will always throw a NullPointerException
Example
Arrays.asList("java").contains(null) => false
List.of("java").contains(null) => NullPointerException

There is several place where the following pattern is apply :
Preconditions.checkArgument(!entrypoint.contains(null), "entrypoint contains null elements");

Passing an ImmutableCollections as entrypoint always fail

Expected behavior:
No NullPointerException exception

Steps to reproduce:

  1. ./gradlew jibDockerBuild

jib-gradle-plugin Configuration:

plugins {
  id 'java-library'
  id 'com.google.cloud.tools.jib' version '2.5.0'
}

java {
  targetCompatibility = JavaVersion.VERSION_11
  sourceCompatibility = JavaVersion.VERSION_11
}

jib {
  container {
    entrypoint = List.of('java', '-jar', 'my-jar')
  }
}

Log output:

Caused by: java.lang.NullPointerException
        at com.google.cloud.tools.jib.configuration.ContainerConfiguration$Builder.setEntrypoint(ContainerConfiguration.java:265)
        at com.google.cloud.tools.jib.api.JibContainerBuilder.setEntrypoint(JibContainerBuilder.java:274)
        at com.google.cloud.tools.jib.plugins.common.PluginConfigurationProcessor.processCommonConfiguration(PluginConfigurationProcessor.java:403)
        at com.google.cloud.tools.jib.plugins.common.PluginConfigurationProcessor.processCommonConfiguration(PluginConfigurationProcessor.java:455)
        at com.google.cloud.tools.jib.plugins.common.PluginConfigurationProcessor.createJibBuildRunnerForDockerDaemonImage(PluginConfigurationProcessor.java:132)
        at com.google.cloud.tools.jib.gradle.BuildDockerTask.buildDocker(BuildDockerTask.java:110)

Additional Information:
I know that not a conventional way to write a List, I'm just trying to provided the shorter possible example.

@loosebazooka
Copy link
Member

so the contains method cannot handle null on the specific implementation of List?

This is a good catch.

@loosebazooka
Copy link
Member

@mpeddada1 can you look into this bug?

@mpeddada1 mpeddada1 self-assigned this Aug 14, 2020
@chanseokoh chanseokoh added this to the v2.6.0 milestone Aug 14, 2020
mpeddada1 added a commit that referenced this issue Aug 19, 2020
* updating changelog
@mpeddada1
Copy link
Contributor

@vgalloy We've released Jib 2.6.0, which contains a fix for this issue. Thanks for reporting!

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

Successfully merging a pull request may close this issue.

4 participants