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

#853: avoid the NullPointerException by providing a default one #939

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yurii-yu
Copy link

fixes #853

implements

  • avoid the NullPointerException by providing a default parent directory

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 12785751311

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 67.807%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/property/PathProperty.java 7 11.94%
Totals Coverage Status
Change from base Build 12770927937: -0.02%
Covered Lines: 6962
Relevant Lines: 9899

💛 - Coveralls

@yurii-yu yurii-yu added bugfix completion auto-completion in bash or build in CLI labels Jan 15, 2025
@yurii-yu yurii-yu self-assigned this Jan 15, 2025
@jan-vcapgemini
Copy link
Contributor

jan-vcapgemini commented Jan 15, 2025

@yurii-yu Thanks for your bugfix approach. I've tested your changes with a local build.
It looks like the issue is not fixed yet:

$ ide repository An unexpected error occurred!
We are sorry for the inconvenience.
Please check the error below, resolve it and try again.
If the error is not on your end (network connectivity, lack of permissions, etc.) please file a bug:
https://github.com/devonfw/IDEasy/issues/new?assignees=&labels=bug&projects=&template=bug.md&title=java.lang.NullPointerException
java.lang.NullPointerException
        at [email protected]/java.nio.file.Files.provider(Files.java:104)
        at [email protected]/java.nio.file.Files.isRegularFile(Files.java:2362)
        at com.devonfw.tools.ide.property.PathProperty.isValidPath(PathProperty.java:128)
        at com.devonfw.tools.ide.property.PathProperty.lambda$completeValue$0(PathProperty.java:119)
        at [email protected]/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:193)
        at [email protected]/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at [email protected]/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
        at [email protected]/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
        at [email protected]/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
        at [email protected]/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at [email protected]/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at [email protected]/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
        at [email protected]/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:611)
        at com.devonfw.tools.ide.property.PathProperty.completeValue(PathProperty.java:119)
        at com.devonfw.tools.ide.property.Property.complete(Property.java:431)
        at com.devonfw.tools.ide.property.Property.apply(Property.java:354)
        at com.devonfw.tools.ide.property.Property.apply(Property.java:338)
        at com.devonfw.tools.ide.context.AbstractIdeContext.completeCommandlet(AbstractIdeContext.java:976)
        at com.devonfw.tools.ide.context.AbstractIdeContext.complete(AbstractIdeContext.java:927)
        at com.devonfw.tools.ide.commandlet.CompleteCommandlet.run(CompleteCommandlet.java:53)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:875)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:805)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:89)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:52)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:29)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

If you want, I could show you how to build the native image and how a test for this issue could look like.

Copy link
Contributor

@jan-vcapgemini jan-vcapgemini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to be not fixed yet. Please check.

@hohwille hohwille added this to the release:2025.01.001 milestone Jan 16, 2025
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurii-yu thanks for your PR and this simple fix 👍
Could you also add the issue #853 to our changelog (see DoD)?
Then we can merge this PR. Thanks!

@hohwille
Copy link
Member

hohwille commented Jan 16, 2025

@yurii-yu Thanks for your bugfix approach. I've tested your changes with a local build.
It looks like the issue is not fixed yet:

@jan-vcapgemini thanks for testing it this way. Really great because that is what I often miss in reviews due to too little time.

IMHO the method isValidPath also needs to be changed to use path argument instead of getValue().
Code seems to be a copy&pasted from validate() method but the author forgot to adjust the copied code properly.

Further we might consider getting the current working directory from IdeContext instead of hardcoding . in parent = Path.of(".").
Then we could add JUnit tests to test this feature and can verify it really works as expected without the need to build a local native image with GraalVM and run a manual test.

@yurii-yu
Copy link
Author

Thank you @jan-vcapgemini and @hohwille
I will test it again and make sure it is fixed, moreover, I will update the changelog following the convention of DoD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix completion auto-completion in bash or build in CLI
Projects
Status: Team Review
Development

Successfully merging this pull request may close these issues.

java.lang.NullPointerException when trying to auto-complete after ide repository
4 participants