Skip to content

Align DOM implementations with org.w3c.dom #5740

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

Merged
merged 8 commits into from
Jul 20, 2025

Conversation

line-o
Copy link
Member

@line-o line-o commented May 14, 2025

Description:

This PR fixes inconsistencies in

  • org.exist.dom.memtree.ElementImpl
  • org.exist.dom.persistent.ElementImpl

with org.w3c.dom.ElementImpl

Because of that a lot of code throughout exist-db core and its extensions needed to be adapted.
So this is definitely a breaking change that developers of Java extensions need to take into account.

On the plus side this also enables us to get rid of a lot of extra checks that were necessary before.
As a result the dependency on apache.commons.lang3.StringUtils could be dropped in several modules.

Reference:

fixes #5672

Type of tests:

None added.

@line-o line-o requested a review from a team as a code owner May 14, 2025 11:24
@line-o line-o added this to v7.0.0 May 14, 2025
Copy link
Member

@reinhapa reinhapa left a comment

Choose a reason for hiding this comment

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

some parts could be converted to switch expressions

@adamretter
Copy link
Contributor

Interestingly, this work looks very similar to the previous work done in Elemental on March 17 2025, see here - evolvedbinary/elemental@f8a2781#diff-5b0c3e472fee91090782d0d1535d50f290ac6f450e8fbe68b30c9dcfad1b6505

I have no problem with you (or anyone else) taking code from Elemental, as long as you follow the license terms. That particular code in Elemental is partly under the LGPL 2.1 ONLY license with an 'Evolved Binary' Copyright. This is not the same license used by eXist-db (which is straight LGPL 2.1 (without the ONLY clause)), and it is not the same Copyright.

If you wish to reuse Elemental code in eXist-db, please do, but you must follow the terms of the LGPL, so as I understand it, at a minimum, you would need to include our license header too in each file where you use our code, and a statement from yourselves if you have made any modifications to our code. You may also need to seek guidance on combining 'LGPL 2.1 ONLY' and 'LGPL 2.1' code as I suspect the outcome of that product is 'LGPL 2.1 ONLY' which is not the license that eXist-db currently claims.

@line-o
Copy link
Member Author

line-o commented May 15, 2025

The license changes in the referenced commit are questionable and I did the changes on my own.
Could you be more specific, @adamretter. Which parts do you allege were copied from the referenced commit?

@reinhapa
Copy link
Member

@adamretter I would be very careful pointing to different licenses and accusing @line-o to have copied from Elemental here.

  • Changing the implementation in order to correctly implement an external defined API will naturally result in similar changes that might also exist in Elemental.
  • Also: How comes that Elemental code contains eXist Source but not the GIT history that lead to it?

@line-o line-o requested review from a team and reinhapa May 15, 2025 09:54
@adamretter
Copy link
Contributor

adamretter commented May 15, 2025

The license changes in the referenced commit are questionable

@line-o I don't yet understand what you mean by "questionable". Do you have questions about them? or do you believe there is a problem with our approach to licensing? We have worked hard to make sure we have followed and complied with the terms of the LGPL 2.1 license. If you believe that there is an issue with our licensing, please feel free to open an issue at https://github.com/evolvedbinary/elemental/issues with the specific details of your concerns in reference to the LGPL license terms.

Which parts do you allege were copied from the referenced commit?

I am not 'alleging' anything, I am simply making an observation.

@adamretter
Copy link
Contributor

adamretter commented May 15, 2025

I would be very careful pointing to different licenses

@reinhapa Can you tell me what I need to be 'careful' of please? The code for eXist-db is 'LGPL 2.1', the modifications in Elemental 6.4.0 and 7.0.0 are 'LGPL 2.1 ONLY'. I don't see how clearly pointing that out should upset anyone, in fact quite to the contrary, it is important for both developers and users to understand the licensing of the software they contribute to and/or use; they need to be 'careful' to adhere to the license terms.

and accusing @line-o to have copied from Elemental here.

I have not made any accusations, I have simply made an observation. If you compare the approach taken, and then also the git diffs you will likely find, as I did, that they are almost identical.

Changing the implementation in order to correctly implement an external defined API will naturally result in similar changes that might also exist in Elemental.

I don't disagree... but, there is more to it than just that here.

Also: How comes that Elemental code contains eXist Source but not the GIT history that lead to it?

Elemental does contain the Git History of eXist-db - git log will show you that. What do you believe is missing?

@line-o line-o marked this pull request as draft May 19, 2025 15:56
@line-o line-o marked this pull request as ready for review June 16, 2025 18:31
@duncdrum
Copy link
Contributor

duncdrum commented Jul 8, 2025

@line-o can you rebase this. The container test shows an error in exist.log we should check that first. If the error stays we can't merge without stopping to push containers

line-o added 6 commits July 9, 2025 15:44
fixes eXist-db#5672

Previously ElementImpl.getAttribute and ElementImpl.getAttributeNodeNS of in memory nodes violated
the API contract of org.w3c.dom.element. It was returning null if an attribute was not set instead
of an empty String.

Fixing this lead to a host of changes throughout the project.
The if-conditions are simplified and even flipped in a few locations were this greatly improved
readability of thd code.
The import of StringUtils was dropped were possible.
- refactor calculateBaseURI to use getAttributeNodeNS to differentiate between unset and empty attribute value
- annotate functions with Nonnull that override Nonnull methods from org.w3c.dom.ElementImpl
- remove deprecated function _getAttributeNS,
- return "" instead on misleading constant in getAttributeNS
- drop dependency on Apache commons-lang3
- refactor AnalyzerConfig.getConstructorParameter and AnalyzerConfig.configureAnalyzer for readability
The last two were the mail module and the LDAP security realm.
@line-o
Copy link
Member Author

line-o commented Jul 9, 2025

@duncdrum the error in docker startup persists. How can we inspect it locally?

@duncdrum
Copy link
Contributor

duncdrum commented Jul 9, 2025

@line-o the logs aren't uploaded anymore automatically we should bring that back.

You would have to build locally start the container and inspect its 'exist.log' There is an 'ERROR' that wasn't there before.

@line-o
Copy link
Member Author

line-o commented Jul 9, 2025

so @duncdrum I think we caught an issue here which might be related to the changes:

09 Jul 2025 18:16:17,612 [main] ERROR (AutoDeploymentTrigger.java [execute]:127) - Exception during deployment of app dashboard-2.0.9.xar: Package requires version  of package [http://www.functx.com.⁠](http://www.functx.com./) Installed version is 1.0.1. Please upgrade! 

org.expath.pkg.repo.PackageException: Package requires version  of package [http://www.functx.com.⁠](http://www.functx.com./) Installed version is 1.0.1. Please upgrade!
	at org.exist.repo.Deployment.installAndDeploy(Deployment.java:232)
	at org.exist.repo.Deployment.installAndDeploy(Deployment.java:156)
	at org.exist.repo.Deployment.installAndDeploy(Deployment.java:248)
	at org.exist.repo.AutoDeploymentTrigger.execute(AutoDeploymentTrigger.java:125)
	at org.exist.storage.StartupTriggersManager.startPreMultiUserSystem(StartupTriggersManager.java:60)
	at org.exist.storage.BrokerPoolServicesManager.startPreMultiUserSystemServices(BrokerPoolServicesManager.java:264)
	at org.exist.storage.BrokerPool._initialize(BrokerPool.java:667)
	at org.exist.storage.BrokerPool.initialize(BrokerPool.java:439)
	at org.exist.storage.BrokerPools.configure(BrokerPools.java:177)
	at org.exist.storage.BrokerPools.configure(BrokerPools.java:112)
	at org.exist.jetty.JettyStart.run(JettyStart.java:244)
	at org.exist.jetty.JettyStart.main(JettyStart.java:126)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.exist.start.Main.invokeMain(Main.java:154)
	at org.exist.start.Main.runEx(Main.java:304)
	at org.exist.start.Main.run(Main.java:159)
	at org.exist.start.Main.main(Main.java:96)

@line-o
Copy link
Member Author

line-o commented Jul 9, 2025

dashboard has the speciality that it defines no version of the functx dependency so this feels very much related.

@line-o line-o self-assigned this Jul 10, 2025
@line-o line-o marked this pull request as draft July 10, 2025 09:58
line-o added 2 commits July 10, 2025 17:59
When handling dependency elements in package descriptor files
the package version attribute was checked in order to determine if
a specific dependency version was pinned for this dependency.

Now that the DOM implementation will always return an empty string
instead of null for unset attributes this now means that

1. the package version is set (otherwise the package would not install)
2. the version variable for each dependency will be non-null because
  the package version is set. The type will then vary on the attribute
  value - this would have been null in the past and is now an empty
  string which changes the resulting DependemcyVersion subtype.
…ements

- move private static class and private enum to the end of the class
- remove unnecessary throw declaration from getPackageDir
- flip if condition at the beginning of installAndDeploy
- fix whitespace and formatting
@duncdrum
Copy link
Contributor

@line-o nice catch, and yay for tests. Good to go now from my side.

@line-o line-o marked this pull request as ready for review July 11, 2025 10:22
Comment on lines +901 to +913
private static class RequestedPerms {
final String user;
final String password;
final Optional<String> group;
final Either<Integer, String> permissions;

private RequestedPerms(final String user, final String password, final Optional<String> group, final Either<Integer, String> permissions) {
this.user = user;
this.password = password;
this.group = group;
this.permissions = permissions;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Might use a record instead of a class here?

Copy link
Member

Choose a reason for hiding this comment

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

makes sense, but I thought a 'switch' change would be in an upcoming PR... but I am wrong as I don't see a remark here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes let's not do too much in one PR.

@dizzzz dizzzz merged commit 51fb3b0 into eXist-db:develop Jul 20, 2025
7 of 9 checks passed
@github-project-automation github-project-automation bot moved this to Done in v7.0.0 Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] org.w3c.dom.Element#getAttribute can't return null
5 participants