-
Notifications
You must be signed in to change notification settings - Fork 0
3648: AVRO-4229 - Update StatsServer resource handler #34
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,8 +20,12 @@ | |||||||
| * limitations under the License. | ||||||||
| */ | ||||||||
| import org.eclipse.jetty.server.Server; | ||||||||
| import org.eclipse.jetty.servlet.ServletHandler; | ||||||||
| import org.eclipse.jetty.server.handler.ContextHandler; | ||||||||
| import org.eclipse.jetty.server.handler.HandlerList; | ||||||||
| import org.eclipse.jetty.server.handler.ResourceHandler; | ||||||||
| import org.eclipse.jetty.servlet.ServletContextHandler; | ||||||||
| import org.eclipse.jetty.servlet.ServletHolder; | ||||||||
| import org.eclipse.jetty.util.resource.Resource; | ||||||||
|
|
||||||||
| /* This is a server that displays live information from a StatsPlugin. | ||||||||
| * | ||||||||
|
|
@@ -42,11 +46,24 @@ public StatsServer(StatsPlugin plugin, int port) throws Exception { | |||||||
| this.httpServer = new Server(port); | ||||||||
| this.plugin = plugin; | ||||||||
|
|
||||||||
| ServletHandler handler = new ServletHandler(); | ||||||||
| httpServer.setHandler(handler); | ||||||||
| handler.addServletWithMapping(new ServletHolder(new StaticServlet()), "/"); | ||||||||
| ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS); | ||||||||
| servletContext.setContextPath("/"); | ||||||||
|
|
||||||||
| handler.addServletWithMapping(new ServletHolder(new StatsServlet(plugin)), "/"); | ||||||||
| ServletHolder servletHolder = new ServletHolder(new StatsServlet(plugin)); | ||||||||
| servletContext.addServlet(servletHolder, "/"); | ||||||||
|
|
||||||||
| ResourceHandler resourceHandler = new ResourceHandler(); | ||||||||
| resourceHandler.setBaseResource(Resource.newClassPathResource("/org/apache/avro/ipc/stats/static")); | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:good-to-have; category:bug; feedback: The Augment AI reviewer is correct! Since the Java package is provided by another Maven module (the "ipc" module) it would be good to add a check that the result of |
||||||||
| resourceHandler.setDirectoriesListed(false); // Optional: prevent directory listing | ||||||||
|
|
||||||||
| ContextHandler staticContext = new ContextHandler(); | ||||||||
| staticContext.setContextPath("/static"); | ||||||||
| staticContext.setHandler(resourceHandler); | ||||||||
|
|
||||||||
| HandlerList handlers = new HandlerList(); | ||||||||
| handlers.setHandlers(new org.eclipse.jetty.server.Handler[] { staticContext, servletContext }); | ||||||||
|
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can initialize the
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:good-to-have; category:bug; feedback: The Gemini AI reviewer is correct! The code could be simplified by using the overloaded constructor that accepts the list of contexts. |
||||||||
|
|
||||||||
| httpServer.setHandler(handlers); | ||||||||
|
|
||||||||
| httpServer.start(); | ||||||||
| } | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This effectively replaces (and deletes) the public
StaticServlet; iforg.apache.avro.ipc.jettyis considered a supported API surface, this is a binary-compatibility break worth double-checking.Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value:incorrect-but-reasonable; category:bug; feedback: The Augment AI reviewer is not correct! The "ipc-jetty" Maven module is an application, not a library, so there is no need to maintain API stability for it.