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

[LOGGING-189] Fix Import-Package entry for org.slf4j. #188

Merged
merged 4 commits into from Mar 17, 2024

Conversation

wilx
Copy link
Contributor

@wilx wilx commented Dec 14, 2023

No description provided.

Copy link
Contributor Author

@wilx wilx left a comment

Choose a reason for hiding this comment

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

@wilx wilx changed the title Fix Import-Package entry for org.slf4j. [LOGGING-189] Fix Import-Package entry for org.slf4j. Dec 14, 2023
pom.xml Outdated
@@ -738,7 +738,7 @@ under the License.
org.apache.log;version="[1.0.1, 1.0.1]";resolution:=optional,
org.apache.log4j;version="[1.2.15, 2.0.0)";resolution:=optional,
org.apache.logging.log4j;version="[2.0, 4.0)";resolution:=optional,
org.slf4j;version="1.7.0, 3.0";resolution:=optional
org.slf4j;version="[1.7.0, 3.0)";resolution:=optional
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if the upper version should be 3.0.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I guess the author wanted all version between 1.7 and less than 3, i.e., all 2.x versions. Seems reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

All the other entries use the same number of parts for the lower and upper limits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the other entries use the same number of parts for the lower and upper limits.

I don't think that matter to OSGi a tall.

@garydgregory
Copy link
Member

Hello @wilx
Thank you for the PR.
How was this tested and how can we avoid breakage in the future?
How about adding a test like https://github.com/apache/commons-compress/blob/master/src/test/java/org/apache/commons/compress/OsgiITest.java here?

@wilx
Copy link
Contributor Author

wilx commented Dec 16, 2023

You can use a BND library macro like I did there. It results in "[1.7.0,3)" which is fine with OSGi.

@wilx
Copy link
Contributor Author

wilx commented Dec 16, 2023

While looking at the imports for the above, I noticed more possible problems. Like, the javax.servlet;version="[2.1.0, 3.0.0)";resolution:=optional, import and its constraint. That should be "[2.1.0,5)" because the 4.0 servlet is compatible with the 2.1.

Is there a log4j2 version 3.x already? Because the constraint here org.apache.logging.log4j;version="[2.0, 4.0)";resolution:=optional, suggests that. It allows >=2 and <4, implying version 3.

@garydgregory
Copy link
Member

@wilx
Thank you for your updates. The issue is that there is no way to validate the changes in your PR without a matching test, see #188 (comment)
This means that a future innocent-looking change could break this and cause a regression.
The test should fail without your changes to the POM.

@garydgregory
Copy link
Member

Ping @wilx 😀

@HannesWell
Copy link
Contributor

I just noticed that also the import of the org.slf4j.spi package is missing, but it is referenced in

This leads to classloading errors when it is attempted to load the Slf4jLogFactory in an OSGi runtime (see e.g. eclipse-mylyn/org.eclipse.mylyn#373).
Would you mind to add that package as well with this PR?

pom.xml Outdated
@@ -738,7 +738,7 @@ under the License.
org.apache.log;version="[1.0.1, 1.0.1]";resolution:=optional,
org.apache.log4j;version="[1.2.15, 2.0.0)";resolution:=optional,
org.apache.logging.log4j;version="[2.0, 4.0)";resolution:=optional,
org.slf4j;version="1.7.0, 3.0";resolution:=optional
org.slf4j;version="[1.7.0, $(versionmask;+;${slf4j.version}))";resolution:=optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
org.slf4j;version="[1.7.0, $(versionmask;+;${slf4j.version}))";resolution:=optional
org.slf4j;version="[1.7.0, $(versionmask;+;${slf4j.version}))";resolution:=optional,
org.slf4j.spi;version="[1.7.0, $(versionmask;+;${slf4j.version}))";resolution:=optional

@HannesWell
Copy link
Contributor

Are there any updates on this change?
As it is, common-logging is hardly usable in OSGi runtimes like Eclipse if the new SLF4JLogFactory is used.

If desired I can create an alternative PR to fix this.

pom.xml Outdated Show resolved Hide resolved
@ppkarwasz
Copy link
Contributor

Is there a log4j2 version 3.x already? Because the constraint here org.apache.logging.log4j;version="[2.0, 4.0)";resolution:=optional, suggests that. It allows >=2 and <4, implying version 3.

There are already beta version of 3.x that have no breaking changes in the API. However we decided recently that log4j-api will stay at version 2.x, so the range should be corrected to [2.0, 3).

Co-authored-by: Piotr P. Karwasz <piotr@github.copernik.eu>
@garydgregory garydgregory merged commit 0f61b80 into apache:master Mar 17, 2024
7 checks passed
garydgregory added a commit that referenced this pull request Mar 17, 2024
@HannesWell
Copy link
Contributor

HannesWell commented Mar 17, 2024

Thanks @garydgregory for pushing this forward.

I just noticed that also the import of the org.slf4j.spi package is missing, but it is referenced in

This leads to classloading errors when it is attempted to load the Slf4jLogFactory in an OSGi runtime (see e.g. eclipse-mylyn/org.eclipse.mylyn#373). Would you mind to add that package as well with this PR?

Has this already been addressed anywhere else?

@garydgregory
Copy link
Member

garydgregory commented Mar 17, 2024

Hello @HannesWell CC @ppkarwasz

I do not know. Please test and/or provide a PR. I am about to create a release candidate for 1.3.1. I can always do a 1.3.2 but the turnaround on a release is at least 4 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants