Skip to content

ApplicationManifestUtils.read() should not throw a NullPointerException on missing attributes in the manifest #790

@bjscde

Description

@bjscde

Hello team,

This is a feature request, which I am raising this on behalf of an end user.

Abstract:
If the manifest file is missing required attibutes, the CF client (2.15) will throw a Nullpointer exception.
The overall request is to make this more significantly more meaningful and rather throw something like a "MissingRequiredAttributesException".

Details:
The method ApplicationManifestUtils.read() parses a CF manifest file.

If the manifest misses required attributes (e.g. the application name), a NullPointerException is thrown, like:

[ex]

java.lang.NullPointerException
at org.cloudfoundry.operations.applications.ApplicationManifestUtils.lambda$null$7(ApplicationManifestUtils.java:207)
at org.cloudfoundry.operations.applications.ApplicationManifestUtils$$Lambda$187/634210724.accept(Unknown Source)
at java.util.ArrayList$Itr.forEachRemaining(ArrayList.java:891)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at org.cloudfoundry.operations.applications.ApplicationManifestUtils.lambda$doRead$8(ApplicationManifestUtils.java:206)
at org.cloudfoundry.operations.applications.ApplicationManifestUtils$$Lambda$186/345893819.accept(Unknown Source)
at java.util.Optional.ifPresent(Optional.java:159)
at org.cloudfoundry.operations.applications.ApplicationManifestUtils.doRead(ApplicationManifestUtils.java:205)
at org.cloudfoundry.operations.applications.ApplicationManifestUtils.read(ApplicationManifestUtils.java:70)
at com.OURCODE.integration.pivotal.PivotalApiApplicationTests.contextLoads(PivotalApiApplicationTests.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

The overall request is to make this behaviour more meaningful.

The CF client should rather:

  • check the manifest for required attributes, and
  • throw a meaningful exception if required attributes are missing and be more concretre about the excption reason. A possible "MissingRequiredAttributesException" is only an example.

Please let us know, whether this can be considered for a future release of the software.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions