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

refactor: get rid of Guava #669

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

refactor: get rid of Guava #669

wants to merge 3 commits into from

Conversation

berezovskyi
Copy link
Contributor

@berezovskyi berezovskyi commented Dec 18, 2024

Description

Gets rid of the Google Guava dependency. Rationale: reduce dependency list both to reduce maintenance burden for us and pass on size reduction for the users.

We only used string blankness checks as well as some immutable collection and stopwatch functionality. All has been replaced by JDK11/17+ code and a small StringUtil class.

Checklist

  • This PR adds an entry to the CHANGELOG. See https://keepachangelog.com/en/1.0.0/ for instructions. Minor edits are exempt.
  • This PR was tested on at least one Lyo OSLC server (e.g. manual workflow on Lyo Sample and OSLC RefImpl) or adds unit/integration tests.
  • This PR does NOT break the API

Issues

Closes #650

(use exactly this syntax to link to issues, one issue per statement only!)

@berezovskyi
Copy link
Contributor Author

This is not a breaking change but in case someone was using Guava classes in their projects without declaring a dependency, the fix is super simple - just add an entry to your POM. This will also help address dependency conflicts in case your project needs an older/newer version of Guava and you want to use Lyo.

@berezovskyi
Copy link
Contributor Author

berezovskyi commented Dec 18, 2024

https://mvnrepository.com/artifact/com.google.guava/guava/33.4.0-jre 3MB, by the way. Lyo Core + Jena provider are barely 100 KB together.

Also replaced Apache Commons Lang3 StringUtils use as well for consistency.

Finally, with the stripping of Unicode Cc category control chars and Unicode normal form C normalization (e.g. Jena can be picky about it sometimes), our StringUtils class punches way above what's in Guava or Commons as far as RDF use is concerned.

@@ -190,7 +187,7 @@ public void testSingleResourceRetrieved()
resource2.getAbout(), ServiceProviderCatalog.class);

Assertions.assertThat(resourceUnderKey).isNotNull();
Assertions.assertThat(resourceUnderKey.getAbout().equals(resource2.getAbout()));
Assertions.assertThat(resourceUnderKey.getAbout()).isEqualTo(resource2.getAbout());
Copy link
Contributor Author

@berezovskyi berezovskyi Dec 18, 2024

Choose a reason for hiding this comment

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

oops, that was a bug - the assertion was not checked

@@ -143,7 +140,7 @@ public void testStoreSuccessiveAddCombines()
ServiceProviderCatalog.class);

Assertions.assertThat(catalogs).hasSize(2);
Assertions.assertThat(Lists.newArrayList(catalogs)
Assertions.assertThat(catalogs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the newer JDKs, stream ops are available directly on a Collection

@@ -53,7 +53,7 @@ public void testSeqMarshalling()
final Model expectedModel = RDFHelper.loadResourceModel("container-element.ttl");
final Container container = new Container();
container.setAbout(URI.create("urn:containerA"));
final ImmutableList<Element> children = ImmutableList.of(element("A"), element("B"));
final List<Element> children = List.of(element("A"), element("B"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

List.of produces an immutable list out of the box.

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

Successfully merging this pull request may close these issues.

Get rid of Guava
1 participant