Skip to content

EVA-4110 upgrade project to Java 21 - spring 3.4#117

Merged
nitin-ebi merged 1 commit into
EBIvariation:java21from
nitin-ebi:java-21-upgrade
May 7, 2026
Merged

EVA-4110 upgrade project to Java 21 - spring 3.4#117
nitin-ebi merged 1 commit into
EBIvariation:java21from
nitin-ebi:java-21-upgrade

Conversation

@nitin-ebi

Copy link
Copy Markdown
Contributor

No description provided.

@nitin-ebi nitin-ebi self-assigned this May 6, 2026
@nitin-ebi nitin-ebi force-pushed the java-21-upgrade branch 2 times, most recently from e7c04d9 to 1c270dc Compare May 6, 2026 13:22
@nitin-ebi nitin-ebi changed the base branch from master to java21 May 6, 2026 13:41
@nitin-ebi nitin-ebi requested review from apriltuesday and tcezard May 6, 2026 13:41
*
* @param query JSON formatted Mongo query
*/
public void setQuery(String query) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the support for String queries. Will have to see if this breaks anything.

If the query is simple enough, we should convert that to a Java/Python query object and use that instead of a string.

Earlier, we had a class from Mongo that was doing the serialization, but that has been removed. So we would have to write something of our own, which is not complicated, but we are trying to do something that is the responsibility of Mongo. Better to avoid if we can

import java.util.Objects;

public class MongoUtils {
public static MongoClientURI constructMongoClientURI(String host, Integer port, String databaseName, String userName,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Class MongoClientURI has been removed and replaced by ConnectionString, so I had to make a few changes accordingly.


@Override
public void doWrite(List<? extends IVariant> variants) {
public void doWrite(Chunk<? extends IVariant> variants) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MongoItemWriter's write method now takes a Chunk instead of a List of items.
This will have a ripple effect, as I assume this is a well-used function.

We can also maybe write an overloaded method that takes a list of items and internally calls this method by converting them to a Chunk. This way, the code in other repos that uses this method can remain as is.

private Stream<? extends T> cursor;

private CloseableIterator<? extends T> cursor;
private Iterator<? extends T> cursorIterator;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need a cursorIterator now, since the cursor has changed in the latest version and does not return an iterator, but returns a stream. This is being used internally by the read method, so it should not have any effect outside in other places.

with:
distribution: temurin
java-version: ${{ matrix.java-version }}
- name: Install and Start MongoDB

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the dependence on an external MongoDB for tests and updated all such tests to use testContainers.

@tcezard tcezard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code change looks good and complete

this.userName = userName;
public MongoConnectionStringBuilder username(final String userName) {
if (Objects.nonNull(userName)) {
this.userName = URLEncoder.encode(userName, StandardCharsets.UTF_8);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did we ever need to URL encode the username ? ONly the password seems to have been needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't need this for our current username; I added it for completeness and consistency.

@apriltuesday apriltuesday left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work! Appreciate the explanatory comments as well.

@nitin-ebi nitin-ebi merged commit ac115a0 into EBIvariation:java21 May 7, 2026
1 check passed
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.

3 participants