-
Notifications
You must be signed in to change notification settings - Fork 369
Closed
Labels
Milestone
Description
In org.glassfish.jersey.server.model.Resource$Builder.mergeResources, we see indexed "get"s of the "resources" list, which at least in some cases is a LinkedList. Calling get( n ) on an LinkedList requires traversal of "n" nodes, which is much slower than an indexed get on an ArrayList.
In our application, this is the flow where we see the problem:
org.glassfish.jersey.server.model.Resource$Builder.mergeResources(Resource.java:573)
org.glassfish.jersey.server.model.Resource$Builder.buildResourceData(Resource.java:602)
org.glassfish.jersey.server.model.Resource$Builder.build(Resource.java:655)
org.glassfish.jersey.server.ResourceBag$Builder.registerModel(ResourceBag.java:121)
org.glassfish.jersey.server.ResourceBag$Builder.registerResource(ResourceBag.java:89)
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:467)
org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:415)```
If the LinkedList only contains a few elements, it's probably not a big deal, but we see it with indexes in the 60's. I believe this only occurs at application initialization time, so should not be a big performance hit at runtime... but still might be worth looking at as a possible optimization.