jedis icon indicating copy to clipboard operation
jedis copied to clipboard

Refine OSGi metadata for JSON dependencies

Open rombert opened this issue 1 year ago • 2 comments

Expected behavior

When deploying in OSGi containers the Jedis bundle has two hard requirements on having the GSON and JSON bundles around. With #3223 and #3249 the dependencies were made optional at runtime (to my understanding).

Additionally, due to an unfortunate interaction between the way the org.json:json bundle does versioning and OSGi metadata requirements OSGi consumers must use the same version as declared in the pom.xml dependencies.

The error messages look something like this.

For missing OSGi bundles

[ERROR] [bundle-packages] redis.clients:jedis:5.1.5: Bundle is importing package org.json with start order 24 but no bundle is exporting these for that start order.
[ERROR] [bundle-packages] redis.clients:jedis:5.1.5: Bundle is importing package com.google.gson;version=[2.10,3) with start order 24 but no bundle is exporting these for that start order in the required version range.

For a version of the org.json:json bundle that is too new

[ERROR] [bundle-packages] redis.clients:jedis:5.1.5: Bundle is importing package org.json;version=[20231013.0,20231014) with start order 24 but no bundle is exporting these for that start order in the required version range.

Actual behavior

The Jedis bundle should resolve in OSGi containers without the JSON and GSON bundlles for deployers who don't use JSON functionality.

The Jedis bundle should resolve in OSGi container with versions of the JSON bundle more recent than the one used in the Jedis pom.xml.

Steps to reproduce:

Please create a reproducible case of your problem. Make sure that case repeats consistently and it's not random

  1. Deploy the Jedis bundle in an OSGi container without any JSON libraries

Redis / Jedis Configuration

Jedis version:

5.1.5

Redis version:

N/A, did not get so far.

Java version:

openjdk 21.0.4 2024-07-16

rombert avatar Sep 12 '24 15:09 rombert

Did you try the solutions available online?

If nothing else works, I think you can bundle your own jar including Jedis and only necessary dependencies.

We would also appreciate any idea/PR to solve this from Jedis end (if possible).

sazzad16 avatar Sep 16 '24 10:09 sazzad16

@sazzad16 - yes, I can rewrap the bundle or just ship the dependencies anyway so I'm not completely blocked. I can look into providing a PR for Jedis to adjust the imports:

  • make the json.org imports open-ended so any future versions are accepted
  • make the json.org and GSON imports optional

Probably not this week but hopefully in the near future.

rombert avatar Sep 16 '24 10:09 rombert