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

#786: Upgrade commandlet #1002

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

hohwille
Copy link
Member

Fixes #786
Improvement of #957

salimbouch and others added 30 commits December 16, 2024 20:26
…Easy into salimbouch-upgrade-commandlet

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@hohwille hohwille added enhancement New feature or request upgrade labels Jan 30, 2025
@hohwille hohwille added this to the release:2025.01.003 milestone Jan 30, 2025
@hohwille
Copy link
Member Author

$ ide upgrade
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=IllegalStateException%3A+Failed+to+resolve+snapshot+version+for+2025.01.003-beta-SNAPSHOT
java.lang.IllegalStateException: Failed to resolve snapshot version for 2025.01.003-beta-SNAPSHOT
        at com.devonfw.tools.ide.repo.MavenRepository.resolveSnapshotVersion(MavenRepository.java:166)
        at com.devonfw.tools.ide.repo.MavenRepository.resolveVersion(MavenRepository.java:130)
        at com.devonfw.tools.ide.repo.MavenRepository.resolveVersion(MavenRepository.java:110)
        at com.devonfw.tools.ide.commandlet.UpgradeCommandlet.run(UpgradeCommandlet.java:121)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:917)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:835)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:95)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:59)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:133)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: javax.xml.xpath.XPathExpressionException: java.util.MissingResourceException: Could not load any resource bundle by com.sun.org.apache.xml.internal.res.XMLErrorResources
        at [email protected]/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:151)
        at com.devonfw.tools.ide.repo.MavenRepository.resolveSnapshotVersion(MavenRepository.java:156)
        ... 9 more
Caused by: java.util.MissingResourceException: Could not load any resource bundle by com.sun.org.apache.xml.internal.res.XMLErrorResources
        at [email protected]/jdk.xml.internal.SecuritySupport.lambda$getResourceBundle$5(SecuritySupport.java:321)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
        at [email protected]/jdk.xml.internal.SecuritySupport.getResourceBundle(SecuritySupport.java:314)
        at [email protected]/jdk.xml.internal.SecuritySupport.getResourceBundle(SecuritySupport.java:303)
        at [email protected]/com.sun.org.apache.xml.internal.res.XMLMessages.createXMLMessage(XMLMessages.java:84)
        at [email protected]/com.sun.org.apache.xml.internal.utils.ObjectPool.getInstance(ObjectPool.java:145)
        at [email protected]/com.sun.org.apache.xml.internal.utils.StringBufferPool.get(StringBufferPool.java:45)
        at [email protected]/com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.getStringValue(DOM2DTM.java:822)
        at [email protected]/com.sun.org.apache.xpath.internal.objects.XNodeSet.getStringFromNode(XNodeSet.java:219)
        at [email protected]/com.sun.org.apache.xpath.internal.objects.XNodeSet.str(XNodeSet.java:282)
        at [email protected]/com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil.getResultAsType(XPathImplUtil.java:151)
        at [email protected]/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:137)
        ... 10 more


Error: IDEasy failed with exit code 255

@hohwille
Copy link
Member Author

I fixed the above error. Next error is:

$ ide upgrade
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=IllegalStateException%3A+Failed+to+resolve+snapshot+version+for+2025.01.003-beta-SNAPSHOT
java.lang.IllegalStateException: Failed to resolve snapshot version for 2025.01.003-beta-SNAPSHOT
        at com.devonfw.tools.ide.repo.MavenRepository.resolveSnapshotVersion(MavenRepository.java:166)
        at com.devonfw.tools.ide.repo.MavenRepository.resolveVersion(MavenRepository.java:130)
        at com.devonfw.tools.ide.repo.MavenRepository.resolveVersion(MavenRepository.java:110)
        at com.devonfw.tools.ide.commandlet.UpgradeCommandlet.run(UpgradeCommandlet.java:123)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:917)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:835)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:95)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:59)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:133)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: javax.xml.xpath.XPathExpressionException: java.lang.RuntimeException: Ausnahme beim Erstellen einer neuen Instanz für Pool
        at [email protected]/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:151)
        at com.devonfw.tools.ide.repo.MavenRepository.resolveSnapshotVersion(MavenRepository.java:156)
        ... 9 more
Caused by: java.lang.RuntimeException: Ausnahme beim Erstellen einer neuen Instanz für Pool
        at [email protected]/com.sun.org.apache.xml.internal.utils.ObjectPool.getInstance(ObjectPool.java:145)
        at [email protected]/com.sun.org.apache.xml.internal.utils.StringBufferPool.get(StringBufferPool.java:45)
        at [email protected]/com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.getStringValue(DOM2DTM.java:822)
        at [email protected]/com.sun.org.apache.xpath.internal.objects.XNodeSet.getStringFromNode(XNodeSet.java:219)
        at [email protected]/com.sun.org.apache.xpath.internal.objects.XNodeSet.str(XNodeSet.java:282)
        at [email protected]/com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil.getResultAsType(XPathImplUtil.java:151)
        at [email protected]/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:137)
        ... 10 more


Error: IDEasy failed with exit code 255

@hohwille
Copy link
Member Author

Source-code from JDK:

     catch (InstantiationException | IllegalAccessException | SecurityException |
              IllegalArgumentException | InvocationTargetException | NoSuchMethodException ex){}

      // Throw unchecked exception for error in pool configuration.
      throw new RuntimeException(XMLMessages.createXMLMessage(
              XMLErrorResources.ER_EXCEPTION_CREATING_POOL, null));
    }

What a disaster. Even JDK has the anti-pattern to loose the original exception on rethrow:
https://github.com/devonfw/IDEasy/blob/main/documentation/coding-conventions.adoc#catching-and-handling-exceptions

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 13062819017

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 178 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.3%) to 68.293%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/version/IdeVersion.java 1 81.82%
com/devonfw/tools/ide/url/model/UrlMetadata.java 4 85.48%
com/devonfw/tools/ide/version/VersionIdentifier.java 9 87.42%
com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java 9 88.46%
com/devonfw/tools/ide/context/IdeContext.java 15 63.92%
com/devonfw/tools/ide/repo/AbstractToolRepository.java 16 60.87%
com/devonfw/tools/ide/context/AbstractIdeContext.java 124 59.32%
Totals Coverage Status
Change from base Build 13062366880: -0.3%
Covered Lines: 7399
Relevant Lines: 10431

💛 - Coveralls

@hohwille
Copy link
Member Author

I have to give up on this for today. I can surely replace the XPath expression back with DOM traversal.
However, after rethinking all of this, I come to the point that we should slightly change the design:

For every local tool we have a subclass of LocalToolCommandlet that can perform the installation and upgrading of the tool. We even solved the windows file locking. We support to switch between versions that have previously be installed with lightning speed by just switching a symlink. We cache the downloads for potential reuse in the central download cache. Etc.

Why do we implement this for IDEasy itself in a totally different way and have to do a strange windows specific hack to prevent the file locking? Also if we ever will make a really bug mistake and release a new version of IDEasy that is broken and cannot run the upgrade commandlet anymore, the user is stick and would have to manually download IDEasy in a previous version and reinstall it.
If we just add a LocalToolCommandlet for IDEasy itself and delegate ide upgrade to it as a kind of "shortcut", we IMHO create a much smarter and consistent design. WDYT?
While I would love to release this feature I currently think we should not do that with brute force.
Maybe we need a little bit more time to make it better and can ship it in the next release.
Since #990 is complete, I will merge this now for the release and then we need to resolve the conflicts here afterwards and rework this PR till it is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upgrade
Projects
Status: Team Review
Development

Successfully merging this pull request may close these issues.

Add UpgradeCommandlet to automatically update to the latest release of IDEasy
4 participants