Video summary
In this session, Michael, a principal developer advocate at GitLab, demonstrates how to modernize legacy Java 8 applications to Java 21 using Cursor and GitLab's dual CI/CD pipeline strategy. The specific use case involves migrating the Java HTTP metrics collector, which currently collects health data from endpoints and stores it in a Rust backend. Rather than attempting a risky "big bang" rewrite, the approach breaks the modernization effort into manageable iterations starting with establishing a baseline. This baseline focuses on configuring CI/CD pipelines to support both Java 8 and Java 21 simultaneously, allowing for parallel testing and validation while gradually updating dependencies like HTTP libraries and virtual threads.
To enable Cursor to understand the project context deeply, the presenter integrates the GitLab Model Context Protocol (MCP) server directly into Cursor's settings. This connection allows the AI assistant to access authenticated data from GitLab instances, including issues, merge requests, and pipeline configurations. By instructing Cursor to address specific work items regarding CI/CD setup and test coverage, the tool successfully fetches relevant files such as pom.xml and .gitlab-ci.yml. The system then generates a summary of the current state, identifying that while the CI/CD baseline is ready, improving test coverage remains an ongoing task that will be addressed in future iterations.
The workflow further showcases GitLab Duo's capabilities through dual code review, where the AI provides real-time feedback on merge requests. In this example, the AI identifies missing JavaDoc comments and potential race conditions in file handling, proposing fixes that align with defined style guide rules requiring documentation for all public methods. Cursor can then automatically address these reviews by generating code changes and pushing updates directly to the repository, effectively simulating a human developer's response to feedback. This seamless loop of review, correction, and re-testing ensures that the migration maintains high code quality standards while keeping both legacy and modern branches stable.
The session concludes with a successful baseline merge request that establishes parallel testing environments for Java 8 and Java 21, setting the stage for deeper modernization efforts in subsequent sessions. The presenter highlights how this strategy reduces risk by validating outputs and compatibility incrementally rather than all at once. Future steps will involve using the established maintenance branch to refactor core components like the HTTP client library. Ultimately, the combination of Cursor's agentic AI capabilities with GitLab's robust CI/CD infrastructure provides a scalable framework for safely evolving legacy codebases without disrupting existing services.
Read the full video transcript
Hello everyone. My name is Michael. I'm
a principal developer advocate here at
GitLab. And in today's session, we want
to look into Kursa together with GitLab
and how Agentic AI can help us with
legacy modernization of code and
applications. Uh for this use case today
we will look into the Java HTTP metrics
collector which is written in Java 8 and
its purpose is to collect metrics from
health and maintenance endpoints and
anything that can be queried from from
that perspective and then store that
into the Rust metrics store back end. Um
that back end has been developed using
the Codex and GitLab series. if if you
have been following along the blog and
video series. Um otherwise we will be
just using it as a back end and focus on
the uh Java matrix collector in that use
case. As I said earlier, Java 8 is the
problem here. Um it's been end of life
for several years now and we want to
modernize it to Java 21 or even newer.
Um there is an epic which outlines a
strategy because u modernization cannot
be like a big bang rewrite and a huge
merger request um hoping that everything
works um but rather much break it down
into smaller iterations testable
artifacts um and also create the
baseline of what is currently supported
in Java 8. Then update CI/CD for
supporting both language standards.
prepare any dependencies, documentation
and whatn not and then further look into
what is required from a language
perspective like modernizing the HTTP
library, modernizing virtual threads and
so on. Um and lastly validating the
outputs and compatibility. So this epic
breaks down a lot of things already.
Um and specifically for this use case
today we want to create a baseline and
by baseline I do mean that we want to
focus on work item number 14 which says
to um add CI/CD for Java 8 and Java 21
has a proposal is very detailed um in
that way and um we can also combine it
with like modernizing the tests. So um
the question here is how can we provide
this rich context into cursor itself. Um
now the keyword is here GitLab MCP or
the GitLab MCP server um to in order to
allow cursor access the um data in
GitLab itself. We can add the MCP server
directly in the cursor settings um
similar to this example here. It's
available on gitlab self-managed on
gitlab dedicated and also on gitlab.com.
In order to do that, let's quickly
switch into cursor over here. And you
can see I already prepared um the
mcp.json file here. It's using
gitlab.com. It's authenticated.
And if I switch to the settings here, we
can see it's um I'm I'm logged in.
Everything is authenticated again
against o already. And here are the
tools that we have available for that.
Now we want to put that into action and
actually look into the changes that we
want to get going with. So let's quickly
go back and extract work item number is
14. And for the second issue that we
will be working on 21. So let's remember
14 and 21. go back into cursor and say
um
please help me modernize
uh this sensor from
Java 8 to 21.
We want to start with
the base line for
CI/CD builds
in work item
14 and then
also look into
test coverage at least what's initially
available
um from
21
start the implementation
in a new g branch called
main
java 21. So we can uh continue testing
different scenarios.
This also provides us with a basis to
experiment to test certain things um but
use that as a baseline um with parallel
CI/CD builds and also test coverage
improvements. Now the expectation here
is that Kosa will use the MCP server uh
to fetch the issues
um and then
checks the different um
implementations like it reads the
pom.xml XML the GitLab CI file
and summarize it what issue 14 is about.
CI/CD issue 21 is a stronger migration
test coverage. It cannot be uh completed
by now. So test coverage needs to
continue while we also modernize the
source code which we will do in a in a
future session. But for now this is it.
And there we have it. Let's open that in
our browser.
Summary. It's closing 14 because CI/CD
is is ready. But the test coverage is an
ongoing task. So it just relates to
that. We can also see it over here on
the right hand side. Then when this
merge request gets merged, it will
automatically close that issue but only
reference um the other one. CI/CD is
running. Um and also we can see at the
bottom that GitLab dual code review
started a session. So we will also get
some review feedback. Um immediately
when that finishes the pipelines can be
inspected here.
So we can see
And we now have the dependency graph for
Java 8 and for Java 21 and different
builds. So for any or for developers who
are used to looking into just the names
for build and test nothing changes and
there's a compatible uh new job for Java
21 also for testing and yeah
and the pipeline is green everything is
okay. Um, let's go back into the match
request.
And we can see here
that GitLab dual code review found
recommendations. It left three comments.
One is about the temp file
which we should potentially fix. And
another one is custom instructions on
Java style guide. Um
there is no Java do. So this is
something we need to also need to fix
and approach.
Um the Java dot is hidden is missing.
Okay, it found something.
um that's different in the
implementation here and makes a proposal
that's also great. So there's multiple
ways how we can propo approach that now.
So for once can use the known pattern
using the dual developer
um flow which can help us like can you
help me address
the review feedback
could be one way to achieve that and
then it would run as a as a session uh
directly on the platform and I can focus
on different things. If I want to change
the scope into cursor again and address
the refere feedback there, I can also do
that. So let's go in and say there is
review feedback in the MR. Please help
me fix it.
Now it also adds a comment directly in
the merge request. Pushes the changes.
You can see the tools here.
It's also replying to the threads
directly.
And let's go back into the issue. Um,
it's using my identity. So, I'm
authenticated against the Gilam MCP
server here. And, um, this resides in me
responding here.
Summarizes the changes. So, again, I can
go back here and
check the changes.
Oh, actually this agent uses a
co-authored by Koser. That's fine. So
you can immediately see who who created
that.
Um the Java dos are fine. And the output
file race condition is also addressed.
That's great. Okay, this triggers
another CSC pipeline.
The thing we could do is um we can also
re re-request a review from GitLab Dual
code review. We can ask um GitLab Duo
developer for example to um add anything
that's missing or any further changes.
We could also uh define triggers um so
when that merge request uh when the
pipeline is okay that's another agent uh
starts running. But for now this is
fine. Um
specifically for the Java do uh
feedback. Let's quickly check in on why
this happened. And this is because of uh
code review rules that are defined here
in the gitlab
uh mr review instructions yammer. And
there is a specific um rule here in the
Java style guide which says all public
methods and classes must have um
describing the purpose and also the
parameter return text. Um this is to
ensure that anything that's gets gets
added as proper documentation and both
humans and agents immediately can gather
the information of what the function or
the class does without reading the
entire source code.
um which can often exceed the context
window itself. Okay, perfect. Now we do
have a merge request and a baseline um
for testing Java 8 and Java 21 in
parallel. Um so to summarize what we did
today in the session u was we had the
modernization task the epic broken down
into specific to issues. Then we pulled
that into cursor using the GitLab MCP
server for our context and cursor was
able to fetch everything like into into
its local context. Worked on the
changes, created a merge request um and
even addressed the merge request review
feedback that in this case GitLab dual
code review added could have done a
human uh developer as well. um and
continued with making um the merge
request user usable in a way to be
approved and merged. And for the next
session uh we will be looking into
actually using that maintenance branch
and make a code change which modernizes
an HTTP client library from Java 8 to
21. So stay tuned for the next session.
I hope you learned something new today.
Yeah, and see you next time. Thanks for
watching and bye-bye.