From 3f2f5d76f2cf8398c8c90c0a4fd07ce66176b883 Mon Sep 17 00:00:00 2001 From: Doug Hilpipre Date: Fri, 20 Dec 2024 06:52:59 -0600 Subject: [PATCH] fixed Java Verify problems --- Mule-Http-1.3/build.gradle | 39 ------- .../mule/http/InboundRequest.java | 106 ------------------ .../mule/http/ResponseWrapper.java | 46 -------- .../GrizzlyRequestDispatcherFilter$1.java | 38 ------- .../GrizzlyRequestDispatcherFilter.java | 87 -------------- 5 files changed, 316 deletions(-) delete mode 100644 Mule-Http-1.3/build.gradle delete mode 100644 Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/InboundRequest.java delete mode 100644 Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/ResponseWrapper.java delete mode 100644 Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter$1.java delete mode 100644 Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter.java diff --git a/Mule-Http-1.3/build.gradle b/Mule-Http-1.3/build.gradle deleted file mode 100644 index 514484a..0000000 --- a/Mule-Http-1.3/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ - -// Build.gradle generated for instrumentation module Mule-Http-1.4 - -apply plugin: 'java' - -dependencies { - implementation 'org.mule.services:mule-service-http:1.3.0' - implementation 'org.mule.runtime:mule-service-http-api:4.2.0' - - - // New Relic Labs Java Agent dependencies - implementation 'com.newrelic.agent.java:newrelic-agent:6.0.0' - implementation 'com.newrelic.agent.java:newrelic-api:6.0.0' - implementation fileTree(include: ['*.jar'], dir: '../libs') -} - -jar { - manifest { - attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.Mule-Http-1.3' - attributes 'Implementation-Vendor': 'New Relic Labs' - attributes 'Implementation-Vendor-Id': 'com.newrelic.labs' - attributes 'Implementation-Version': 1.0 - } -} - -verifyInstrumentation { - passes("org.mule.services:mule-service-http:(1.3.0,1.4.0)") { - compile 'org.mule.runtime:mule-service-http-api:4.3.0' - } - passes("org.mule.services:mule-service-http:(1.4.0,1.5.18)") { - compile 'org.mule.runtime:mule-service-http-api:4.3.0' - } -// passes("org.mule.services:mule-service-http:[1.6.0,)") { -// compile 'org.mule.runtime:mule-service-http-api:4.3.0' -// } - excludeRegex '.*MULE.*' - excludeRegex '.*SNAPSHOT.*' - excludeRegex '.*-M.*' -} \ No newline at end of file diff --git a/Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/InboundRequest.java b/Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/InboundRequest.java deleted file mode 100644 index b86e840..0000000 --- a/Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/InboundRequest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.nr.instrumentation.mule.http; - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.StringTokenizer; - -import org.glassfish.grizzly.http.HttpRequestPacket; -import org.glassfish.grizzly.http.util.DataChunk; - -import com.newrelic.api.agent.ExtendedRequest; -import com.newrelic.api.agent.HeaderType; - -public class InboundRequest extends ExtendedRequest { - - private HttpRequestPacket request = null; - - public InboundRequest(HttpRequestPacket packet) { - request = packet; - } - - @Override - public String getRequestURI() { - return request.getRequestURI(); - } - - @Override - public String getRemoteUser() { - DataChunk remoteUserChuck = request.remoteUser(); - if(remoteUserChuck != null) { - return remoteUserChuck.toString(); - } - return null; - } - - @SuppressWarnings("rawtypes") - @Override - public Enumeration getParameterNames() { - String queryString = request.getQueryString(); - if(queryString != null && !queryString.isEmpty()) { - StringTokenizer st = new StringTokenizer(queryString, "&"); - List list = new ArrayList(); - - while(st.hasMoreTokens()) { - String token = st.nextToken(); - int index = token.indexOf('='); - if(index > 0) { - String tmp = token.substring(0, index-1); - list.add(tmp); - } - } - return Collections.enumeration(list); - } - return null; - } - - @Override - public String[] getParameterValues(String name) { - String queryString = request.getQueryString(); - if(queryString != null && !queryString.isEmpty()) { - StringTokenizer st = new StringTokenizer(queryString, "&"); - List list = new ArrayList(); - - while(st.hasMoreTokens()) { - String token = st.nextToken(); - int index = token.indexOf('='); - if(index > 0) { - String tmp = token.substring(index+1); - list.add(tmp); - } - } - String[] values = new String[list.size()]; - list.toArray(values); - return values; - } - return null; - } - - @Override - public Object getAttribute(String name) { - return request.getAttribute(name); - } - - @Override - public String getCookieValue(String name) { - return null; - } - - @Override - public HeaderType getHeaderType() { - return HeaderType.HTTP; - } - - @Override - public String getHeader(String name) { - return request.getHeader(name); - } - - @Override - public String getMethod() { - return request.getMethod().getMethodString(); - } - -} diff --git a/Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/ResponseWrapper.java b/Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/ResponseWrapper.java deleted file mode 100644 index 379a4a3..0000000 --- a/Mule-Http-1.3/src/main/java/com/nr/instrumentation/mule/http/ResponseWrapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.nr.instrumentation.mule.http; - -import org.glassfish.grizzly.http.HttpResponsePacket; - -import com.newrelic.api.agent.ExtendedResponse; -import com.newrelic.api.agent.HeaderType; - -public class ResponseWrapper extends ExtendedResponse { - - private HttpResponsePacket response = null; - - public ResponseWrapper(HttpResponsePacket resp) { - response = resp; - } - - @Override - public String getContentType() { - return response.getContentType(); - } - - @Override - public int getStatus() throws Exception { - return response.getStatus(); - } - - @Override - public String getStatusMessage() throws Exception { - return response.getReasonPhrase(); - } - - @Override - public HeaderType getHeaderType() { - return HeaderType.HTTP; - } - - @Override - public void setHeader(String name, String value) { - response.setHeader(name, value); - } - - @Override - public long getContentLength() { - return response.getContentLength(); - } - -} diff --git a/Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter$1.java b/Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter$1.java deleted file mode 100644 index 2f2c42b..0000000 --- a/Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter$1.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.mule.service.http.impl.service.server.grizzly; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.weaver.NewField; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.WeaveAllConstructors; -import com.newrelic.api.agent.weaver.Weaver; - -@Weave -abstract class GrizzlyRequestDispatcherFilter$1 { - - @NewField - private Token token = null; - - @WeaveAllConstructors - GrizzlyRequestDispatcherFilter$1() { - if(token == null) { - Token t = NewRelic.getAgent().getTransaction().getToken(); - if(t != null && t.isActive()) { - token = t; - } else if(t != null) { - t.expire(); - t = null; - } - } - } - - @Trace(async = true) - public void responseReady(org.mule.runtime.http.api.domain.message.response.HttpResponse resp, org.mule.runtime.http.api.server.async.ResponseStatusCallback callback) { - if(token != null) { - token.linkAndExpire(); - token = null; - } - Weaver.callOriginal(); - } -} diff --git a/Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter.java b/Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter.java deleted file mode 100644 index dc9f93d..0000000 --- a/Mule-Http-1.3/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyRequestDispatcherFilter.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.mule.service.http.impl.service.server.grizzly; - -import java.net.InetSocketAddress; - -import org.glassfish.grizzly.filterchain.FilterChainContext; -import org.glassfish.grizzly.filterchain.FilterChainEvent; -import org.glassfish.grizzly.filterchain.NextAction; -import org.glassfish.grizzly.http.HttpContent; -import org.glassfish.grizzly.http.HttpRequestPacket; -import org.glassfish.grizzly.http.HttpResponsePacket; -import org.mule.service.http.impl.service.server.DefaultServerAddress; -import org.mule.service.http.impl.service.server.RequestHandlerProvider; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Trace; -import com.newrelic.api.agent.Transaction; -import com.newrelic.api.agent.TransactionNamePriority; -import com.newrelic.api.agent.weaver.Weave; -import com.newrelic.api.agent.weaver.Weaver; -import com.nr.instrumentation.mule.http.InboundRequest; -import com.nr.instrumentation.mule.http.ResponseWrapper; - -@Weave -public abstract class GrizzlyRequestDispatcherFilter { - - private final RequestHandlerProvider requestHandlerProvider = Weaver.callOriginal(); - - GrizzlyRequestDispatcherFilter(RequestHandlerProvider requestHandlerProvider) { - } - - @Trace(dispatcher=true) - public NextAction handleRead(final FilterChainContext ctx) { - InetSocketAddress tmpLocal = (InetSocketAddress) ctx.getConnection().getLocalAddress(); - DefaultServerAddress tmpServerAdd = new DefaultServerAddress(tmpLocal.getAddress(), tmpLocal.getPort()); - - if(!requestHandlerProvider.hasHandlerFor(tmpServerAdd)) { - String msg = "Failed to find a request handler for address: " + tmpLocal.toString(); - NewRelic.noticeError(msg); - } - - Transaction txn = NewRelic.getAgent().getTransaction(); - if(!txn.isWebTransaction()) { - txn.convertToWebTransaction(); - } - if(ctx.getMessage() instanceof HttpContent) { - HttpContent httpContent = (HttpContent) ctx.getMessage(); - HttpRequestPacket request = (HttpRequestPacket) httpContent.getHttpHeader(); - if(request != null) { - String requestURI = request.getRequestURI(); - if(requestURI != null) { - if(requestURI.isEmpty()) { - requestURI = "Root"; - } - NewRelic.getAgent().getTransaction().setTransactionName(TransactionNamePriority.REQUEST_URI, true, "Grizzly", "GrizzlyDispatcher"); - } - InboundRequest wrapper = new InboundRequest(request); - txn.setWebRequest(wrapper); - HttpResponsePacket response = request.getResponse(); - NewRelic.getAgent().getTransaction().setWebResponse(new ResponseWrapper(response)); - } - - } - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","GrizzlyRequestDispatcherFilter","handleRead",ctx.getMessage().getClass().getSimpleName()}); - return Weaver.callOriginal(); - } - - @Trace(dispatcher=true) - public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event) { - String msgClass = "UnknownMessageClass"; - String eventClass = "UnknownEventClass"; - - if(ctx != null) { - Object msg = ctx.getMessage(); - if(msg != null) { - msgClass = msg.getClass().getSimpleName(); - } - } - if(event != null) { - eventClass = event.getClass().getSimpleName(); - } - - NewRelic.getAgent().getTracedMethod().setMetricName(new String[] {"Custom","GrizzlyRequestDispatcherFilter","handleEvent",msgClass,eventClass}); - - return Weaver.callOriginal(); - } - -}