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 on Maven if only one of username or password is set #1177

Closed
chanseokoh opened this issue Oct 22, 2018 · 0 comments
Closed

NPE on Maven if only one of username or password is set #1177

chanseokoh opened this issue Oct 22, 2018 · 0 comments
Assignees
Milestone

Comments

@chanseokoh
Copy link
Member

        <configuration>
          <to>
            <image>...</image>
            <auth><username>abc</username></auth>
          </to>
        </configuration>

We have code to give a nice error message If either username or password is set only:

    if (Strings.isNullOrEmpty(auth.getUsername())) {
      eventDispatcher.dispatch(
          LogEvent.warn(
              auth.getUsernamePropertyDescriptor()
                  + " is missing from build configuration; ignoring auth section."));
      return Optional.empty();
    }

However, the checkNotNull inside auth.getUsernamePropertyDescriptor() is failing with the sample config above. Note we set the property descriptor in the JibPluginConfiguration constructor.

  JibPluginConfiguration() {
    to.auth.setPropertyDescriptor("<to><auth>");
    from.auth.setPropertyDescriptor("<from><auth>");
  }

Therefore, when JibPluginConfiguration is created, the property descriptors cannot possible by null. So, I think it may be that if the <auth> section is defined, a new AuthConfiguration instance is created, replacing the one that has property descriptors set by the JibPluginConfiguration?

Caused by: java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:871)
        at com.google.cloud.tools.jib.maven.JibPluginConfiguration$AuthConfiguration.getPasswordPropertyDescriptor(JibPluginConfiguration.java:59)
        at com.google.cloud.tools.jib.plugins.common.ConfigurationPropertyValidator.getImageCredential(ConfigurationPropertyValidator.java:99)
        at com.google.cloud.tools.jib.maven.BuildImageMojo.execute(BuildImageMojo.java:107)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more

Haven't tested Gradle.

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

No branches or pull requests

3 participants