Repository navigation
OAK-12503 : support slf4j 1.7 and 2.0 - #3259
rishabhdaim wants to merge 6 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Widening the import version range is not reasonable. Either you leverage 1.x API or 2.x. The latter is largely backwards compatible therefore SLf4J 2.x also exports 1.x package versions. However 2.x adds new API clearly not provided by 1.x. So in order to be compatible with both you should:
- depend on 1.x API only
- import 1.x package versions only
otherwise an Oak bundle may non deliberately depend on SLF4j (but incorrectly resolve with SLF4J 1.x) and fail at run time.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@reschke, no we don't have to compile against 2.x. We just migrated to 2.x because we could. |
|
ok, so just go back to slf4j 1.x |
That's what this PR does, right? (plus testing with 2.x). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@mbaedke thanks for review. |
| </Export-Package> | ||
| <Import-Package> | ||
| <!-- Embedded Commons Logging uses LocationAwareLogger in both SLF4J generations. --> | ||
| org.slf4j.spi;version="[1.7,3)", |
There was a problem hiding this comment.
This increased import range I consider still wrong. The default one from Bnd is correct and SLF4J still exports package version 1.x.
There was a problem hiding this comment.
I checked the generated manifests and ran the OSGi tests with and without the override.
With SLF4J 1.7.36, bnd 6.3.1 generates org.slf4j.spi;version="[1.7,2)" by default.
SLF4J 2.0.20 exports org.slf4j.spi only at version 2.0.20.
Its additional 1.7.36 compatibility exports cover org.slf4j and org.slf4j.helpers, but not org.slf4j.spi.
See SLF4J’s export configuration.
Without the override, bnd generates [1.7,2), which rejects SLF4J 2.0’s SPI package.
I reproduced the resulting LocationAwareLogger loading failure; restoring [1.7,3) made the tests pass.
There was a problem hiding this comment.
org.slf4j.spi is not backwards compatible, only org.slf4j. Widening the import version range doesn't make it magically backwards compatible either. That the test don't run into issues probably just proofs that they are not complete. See discussion at qos-ch/slf4j#358 and https://jira.qos.ch/browse/SLF4J-579.
Particularly pay attention to
The package-info for org.slf4j.spi states that this package should not be used by clients.
There was a problem hiding this comment.
Agreed that SLF4J does not guarantee compatibility for the entire SPI package; this exception preserves the embedded Commons Logging 1.3.5 bundle's own optional [1.7,3) SPI import.
In 110fe7d0c0, I clarified the POM comment and changed the test to use LogFactory.getLog with the real OSGi provider, checking enabled/disabled levels, throwable identity and caller location: all 9 OSGi tests pass on both SLF4J 1.7.36 / Logback 1.2.13 and SLF4J 2.0.20 / Logback 1.6.4, while removing the override reproduces two LocationAwareLogger loading errors.
There was a problem hiding this comment.
Ok, so commons-logging itself has a widened import range there, no problem. The AWS SDK apparently only uses org.slf4j.event.Level without calling any 2.x-specific methods, so it will work de facto with the widened range (and apparently it used to work in Oak with 1.x in the past and 2.x now), so I guess we can do this. But I'd really prefer if we keep this temporary and go fully 2.x ASAP.
There was a problem hiding this comment.
@mbaedke, yes, the goal is that this is a temporary arrangement, and we would probably remove the support for 1.x in future releases.
Co-Authored-By: OpenAI Codex <noreply@openai.com>
|



Summary
Compile Oak libraries against SLF4J 1.7.36 to prevent accidental use of 2.x-only APIs. Preserve the modern logging stack introduced by OAK-10339 for runnable tools, benchmarks and examples.
Changes
oak-blob-cloudimportsorg.slf4j.eventwith[1.7,3), andoak-search-elasticpreserves Commons Logging 1.3.5's declaredorg.slf4j.spirange[1.7,3). These are dependency-specific exceptions, not a claim that SLF4J guarantees compatibility for the entire SPI package.LogFactory.getLogand the actual SLF4J provider, including enabled/disabled levels, throwable identity, and caller location. Start the logging provider before framework consumers and prevent Maven-classpath provider leakage in the OSGi fixture.Test Plan
OSGiIT: all 9 tests pass on SLF4J 1.7.36 / Logback 1.2.13 and SLF4J 2.0.20 / Logback 1.6.4. Removing the SPI override reproduces twoLocationAwareLoggerloading errors; restoring it passes.The cloud check validates logging requirements, not configured S3 activation or optional SDK SPI linkage.
Links
Co-Authored-By: GitHub Copilot copilot@github.com
Co-Authored-By: OpenAI Codex noreply@openai.com