Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.glassfish.grizzly.http.util.DataChunk;
import org.glassfish.grizzly.http.util.MimeHeaders;

public class GrizzlyHttpResponseMutator implements HttpServerResponseMutator<HttpResponsePacket> {
public enum GrizzlyHttpResponseMutator implements HttpServerResponseMutator<HttpResponsePacket> {
INSTANCE;

@Override
public void appendHeader(HttpResponsePacket response, String name, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void onEnter(
@Advice.Argument(2) HttpResponsePacket response) {
Context context = GrizzlyStateStorage.getContext(ctx);
HttpServerResponseCustomizerHolder.getCustomizer()
.customize(context, response, new GrizzlyHttpResponseMutator());
.customize(context, response, GrizzlyHttpResponseMutator.INSTANCE);
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator;
import org.eclipse.jetty.server.Response;

class Jetty12ResponseMutator implements HttpServerResponseMutator<Response> {
enum Jetty12ResponseMutator implements HttpServerResponseMutator<Response> {
INSTANCE;

@Override
public void appendHeader(Response response, String name, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static AdviceScope start(Request request, Response response) {
Context context = helper().start(parentContext, request, response);
Scope scope = context.makeCurrent();
HttpServerResponseCustomizerHolder.getCustomizer()
.customize(context, response, new Jetty12ResponseMutator());
.customize(context, response, Jetty12ResponseMutator.INSTANCE);
return new AdviceScope(context, scope);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static AdviceScope start(HttpServletRequest request, HttpServletResponse
// Must be set here since Jetty handlers can use startAsync outside of servlet scope.
helper().setAsyncListenerResponse(context, response);
HttpServerResponseCustomizerHolder.getCustomizer()
.customize(context, response, new Jetty8ResponseMutator());
.customize(context, response, Jetty8ResponseMutator.INSTANCE);
return new AdviceScope(requestContext, context, scope);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator;
import javax.servlet.http.HttpServletResponse;

final class Jetty8ResponseMutator implements HttpServerResponseMutator<HttpServletResponse> {
enum Jetty8ResponseMutator implements HttpServerResponseMutator<HttpServletResponse> {
INSTANCE;

@Override
public void appendHeader(HttpServletResponse response, String name, String value) {
response.addHeader(name, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public static void onEnter() {
helper().setAsyncListenerResponse(context, requestInfo.getResponse());

HttpServerResponseCustomizerHolder.getCustomizer()
.customize(context, requestInfo.getResponse(), new Servlet3HttpServerResponseMutator());
.customize(
context, requestInfo.getResponse(), Servlet3HttpServerResponseMutator.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator;
import javax.servlet.http.HttpServletResponse;

public class Servlet3HttpServerResponseMutator
public enum Servlet3HttpServerResponseMutator
implements HttpServerResponseMutator<HttpServletResponse> {
public static final Servlet3HttpServerResponseMutator INSTANCE =
new Servlet3HttpServerResponseMutator();
INSTANCE;

@Override
public void appendHeader(HttpServletResponse response, String name, String value) {
Expand Down
Loading