Skip to content

Conversation

@terjekid
Copy link

What is the purpose of the change

This pull request improves ipc StatsServer, fixing AVRO-4229

Verifying this change

This change is already covered by existing tests, such as TestStatsPluginAndServlet.

Documentation

  • Does this pull request introduce a new feature? no

@github-actions github-actions bot added the Java Pull Requests for Java binding label Feb 12, 2026

import org.apache.avro.ipc.stats.StatsPlugin;
import org.apache.avro.ipc.stats.StatsServlet;
/*
Copy link
Member

Choose a reason for hiding this comment

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

Not caused by this PR but we could improve it.
The ASFv2 licence should be at the top of the file.

Comment on lines +63 to +64
HandlerList handlers = new HandlerList();
handlers.setHandlers(new org.eclipse.jetty.server.Handler[] { staticContext, servletContext });
Copy link
Member

Choose a reason for hiding this comment

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

this can be simplified to:

Suggested change
HandlerList handlers = new HandlerList();
handlers.setHandlers(new org.eclipse.jetty.server.Handler[] { staticContext, servletContext });
HandlerList handlers = new HandlerList(staticContext, servletContext);

servletContext.addServlet(servletHolder, "/");

ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setBaseResource(Resource.newClassPathResource("/org/apache/avro/ipc/stats/static"));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
resourceHandler.setBaseResource(Resource.newClassPathResource("/org/apache/avro/ipc/stats/static"));
Resource baseResource = Resource.newClassPathResource("/org/apache/avro/ipc/stats/static");
if (baseResource == null) {
throw new IllegalStateException("Static resources not found on classpath");
}
resourceHandler.setBaseResource(baseResource);

since the classpath is provided by another Maven module IMO it would be good to make this check here and fail early if for some reason this package is not available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants