From 425994878801f92092f1988c1b124996eeeff552 Mon Sep 17 00:00:00 2001 From: Jose Montoya Date: Sat, 11 Jul 2020 17:04:23 -0500 Subject: [PATCH] mule: remove http-service --- opentracing-specialagent/pom.xml | 7 - rule/mule-4-http-service/README.md | 11 -- rule/mule-4-http-service/pom.xml | 135 ------------------ .../http/MuleFilterChainAgentIntercept.java | 31 ---- .../http/MuleFilterChainAgentRule.java | 72 ---------- .../http/TracedMuleFilterChainBuilder.java | 41 ------ .../src/main/resources/otarules.mf | 15 -- .../mule4/service/http/HttpServiceTest.java | 75 ---------- rule/pom.xml | 1 - test/mule/mule-4.2.2/pom.xml | 2 +- 10 files changed, 1 insertion(+), 389 deletions(-) delete mode 100644 rule/mule-4-http-service/README.md delete mode 100644 rule/mule-4-http-service/pom.xml delete mode 100644 rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentIntercept.java delete mode 100644 rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentRule.java delete mode 100644 rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/TracedMuleFilterChainBuilder.java delete mode 100644 rule/mule-4-http-service/src/main/resources/otarules.mf delete mode 100644 rule/mule-4-http-service/src/test/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/HttpServiceTest.java diff --git a/opentracing-specialagent/pom.xml b/opentracing-specialagent/pom.xml index b06113544..52c24bdc5 100644 --- a/opentracing-specialagent/pom.xml +++ b/opentracing-specialagent/pom.xml @@ -470,13 +470,6 @@ true provided - - io.opentracing.contrib.specialagent.rule - mule-4-http-service - ${project.version} - true - provided - io.opentracing.contrib.specialagent.rule mule-4-module-artifact diff --git a/rule/mule-4-http-service/README.md b/rule/mule-4-http-service/README.md deleted file mode 100644 index 88980a107..000000000 --- a/rule/mule-4-http-service/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# SpecialAgent Rule for Mule 4 HTTP Service - -**Rule Name:** `mule:http-service:4` - -## Compatibility - -```xml -org.mule.runtime -mule-module-artifact -[4.2.2,4.0.0-M5),(4.0.0-M5.2,LATEST] -``` \ No newline at end of file diff --git a/rule/mule-4-http-service/pom.xml b/rule/mule-4-http-service/pom.xml deleted file mode 100644 index c997eade0..000000000 --- a/rule/mule-4-http-service/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - 4.0.0 - - io.opentracing.contrib.specialagent.rule - rule - 1.7.4-SNAPSHOT - - mule-4-http-service - SpecialAgent Rule for Mule 4 HTTP Service - - 1.8 - 1.8 - mule:http-service:4 - 1.4.7 - org.mule.services:mule-service-http:[${min.version},4.0.0-M5),(4.0.0-M5.2,] - 0.1.3 - 4.2.2 - 2.11.2 - - - - org.mule.services - mule-service-http - ${min.version} - true - provided - - - - io.opentracing.contrib - opentracing-grizzly-http-server - ${version.opentracing.grizzly.http.server} - true - - - io.opentracing.contrib - opentracing-grizzly-http-server - ${version.opentracing.grizzly.http.server} - test-jar - test - - - org.mule.runtime - mule-core - ${version.mule} - true - test - - - org.mule.runtime - mule-extensions-api - 1.2.2 - true - test - - - org.mule.runtime - mule-service-http-api - ${version.mule} - true - test - - - org.mule.tests - mule-tests-unit - ${version.mule} - true - test - - - org.apache.logging.log4j - log4j-api - ${version.apache-logging} - true - test - - - org.apache.logging.log4j - log4j-core - ${version.apache-logging} - true - test - - - org.apache.httpcomponents - fluent-hc - 4.5.2 - true - test - - - - - anypoint-exchange-v2 - Anypoint Exchange - https://maven.anypoint.mulesoft.com/api/v2/maven - default - - - mulesoft-releases - MuleSoft Releases Repository - https://repository.mulesoft.org/releases/ - default - - - - - mulesoft-releases - mulesoft release repository - default - https://repository.mulesoft.org/releases/ - - false - - - - \ No newline at end of file diff --git a/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentIntercept.java b/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentIntercept.java deleted file mode 100644 index 5a1f90cef..000000000 --- a/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentIntercept.java +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2019 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentracing.contrib.specialagent.rule.mule4.service.http; - -import org.glassfish.grizzly.filterchain.FilterChainBuilder; - -import io.opentracing.contrib.specialagent.AgentRuleUtil; -import io.opentracing.util.GlobalTracer; -import net.bytebuddy.asm.Advice; - -public class MuleFilterChainAgentIntercept { - public static Object enter(final @Advice.This Object thiz) { - if (AgentRuleUtil.callerEquals(1, 3, "io.opentracing.contrib.grizzly.http.server.TracedFilterChainBuilder.build")) - return null; - - return new TracedMuleFilterChainBuilder((FilterChainBuilder)thiz, GlobalTracer.get()).build(); - } -} \ No newline at end of file diff --git a/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentRule.java b/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentRule.java deleted file mode 100644 index 84642797a..000000000 --- a/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/MuleFilterChainAgentRule.java +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2019 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentracing.contrib.specialagent.rule.mule4.service.http; - -import static net.bytebuddy.matcher.ElementMatchers.*; - -import io.opentracing.contrib.specialagent.AgentRule; -import io.opentracing.contrib.specialagent.EarlyReturnException; -import net.bytebuddy.agent.builder.AgentBuilder; -import net.bytebuddy.agent.builder.AgentBuilder.Identified.Narrowable; -import net.bytebuddy.agent.builder.AgentBuilder.Transformer; -import net.bytebuddy.asm.Advice; -import net.bytebuddy.description.type.TypeDescription; -import net.bytebuddy.dynamic.DynamicType.Builder; -import net.bytebuddy.implementation.bytecode.assign.Assigner.Typing; -import net.bytebuddy.utility.JavaModule; - -public class MuleFilterChainAgentRule extends AgentRule { - @Override - public AgentBuilder[] buildAgentUnchained(final AgentBuilder builder) { - final Narrowable narrowable = builder.type(named("org.glassfish.grizzly.filterchain.FilterChainBuilder$StatelessFilterChainBuilder")); - return new AgentBuilder[] { - narrowable - .transform(new Transformer() { - @Override - public Builder transform(final Builder builder, final TypeDescription typeDescription, final ClassLoader classLoader, final JavaModule module) { - return builder.visit(advice(typeDescription).to(OnEnter.class).on(named("build"))); - }}), - narrowable - .transform(new Transformer() { - @Override - public Builder transform(final Builder builder, final TypeDescription typeDescription, final ClassLoader classLoader, final JavaModule module) { - return builder.visit(advice(typeDescription).to(OnExit.class).on(named("build"))); - }})}; - } - - public static class OnEnter { - @Advice.OnMethodEnter - public static void enter(final @ClassName String className, final @Advice.Origin String origin, final @Advice.This Object thiz) throws EarlyReturnException { - if (!isAllowed(className, origin)) - return; - - final Object filterChain = MuleFilterChainAgentIntercept.enter(thiz); - if (filterChain != null) - throw new EarlyReturnException(filterChain); - } - } - - public static class OnExit { - @SuppressWarnings("unused") - @Advice.OnMethodExit(onThrowable = Throwable.class) - public static void exit(@Advice.Return(readOnly = false, typing = Typing.DYNAMIC) Object returned, @Advice.Thrown(readOnly = false, typing = Typing.DYNAMIC) Throwable thrown) { - if (thrown instanceof EarlyReturnException) { - returned = ((EarlyReturnException)thrown).getReturnValue(); - thrown = null; - } - } - } -} \ No newline at end of file diff --git a/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/TracedMuleFilterChainBuilder.java b/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/TracedMuleFilterChainBuilder.java deleted file mode 100644 index c9b178009..000000000 --- a/rule/mule-4-http-service/src/main/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/TracedMuleFilterChainBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2019 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentracing.contrib.specialagent.rule.mule4.service.http; - -import org.glassfish.grizzly.filterchain.FilterChain; -import org.glassfish.grizzly.filterchain.FilterChainBuilder; -import org.mule.service.http.impl.service.server.grizzly.GrizzlyRequestDispatcherFilter; - -import io.opentracing.Tracer; -import io.opentracing.contrib.grizzly.http.server.TracedFilterChainBuilder; - -public class TracedMuleFilterChainBuilder extends TracedFilterChainBuilder { - public TracedMuleFilterChainBuilder(final FilterChainBuilder builder, final Tracer tracer) { - super(builder, tracer); - } - - @Override - public FilterChain build() { - final int dispatcherFilter = this.indexOfType(GrizzlyRequestDispatcherFilter.class); - if (dispatcherFilter != -1) { - // If contains an GrizzlyRequestDispatcherFilter - // @see https://github.com/mulesoft/mule-http-service/blob/1.4.7/src/main/java/org/mule/service/http/impl/service/server/grizzly/GrizzlyServerManager.java#L111 - addTracingFiltersAt(4); - } - - return super.build(); - } -} \ No newline at end of file diff --git a/rule/mule-4-http-service/src/main/resources/otarules.mf b/rule/mule-4-http-service/src/main/resources/otarules.mf deleted file mode 100644 index 0ea05b137..000000000 --- a/rule/mule-4-http-service/src/main/resources/otarules.mf +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2019 The OpenTracing Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -io.opentracing.contrib.specialagent.rule.mule4.service.http.MuleFilterChainAgentRule diff --git a/rule/mule-4-http-service/src/test/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/HttpServiceTest.java b/rule/mule-4-http-service/src/test/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/HttpServiceTest.java deleted file mode 100644 index 4eeec67c0..000000000 --- a/rule/mule-4-http-service/src/test/java/io/opentracing/contrib/specialagent/rule/mule4/service/http/HttpServiceTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright 2020 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentracing.contrib.specialagent.rule.mule4.service.http; - -import static org.junit.Assert.*; - -import org.apache.http.client.fluent.Request; -import org.apache.http.client.fluent.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mule.runtime.core.api.util.ClassUtils; -import org.mule.runtime.http.api.server.HttpServer; -import org.mule.runtime.http.api.server.HttpServerConfiguration; -import org.mule.service.http.impl.service.HttpServiceImplementation; -import org.mule.tck.SimpleUnitTestSupportSchedulerService; -import org.mule.tck.junit4.AbstractMuleTestCase; - -import io.opentracing.contrib.specialagent.AgentRunner; -import io.opentracing.mock.MockTracer; - -@RunWith(AgentRunner.class) -public class HttpServiceTest extends AbstractMuleTestCase { - private static final String HOST = "localhost"; - private static final int PORT = 9875; - private HttpServiceImplementation service; - private SimpleUnitTestSupportSchedulerService schedulerService; - private HttpServer server; - - @Before - public void before(final MockTracer tracer) throws Exception { - tracer.reset(); - - schedulerService = new SimpleUnitTestSupportSchedulerService(); - service = (HttpServiceImplementation)ClassUtils.instantiateClass(HttpServiceImplementation.class.getName(), new Object[] {schedulerService}, this.getClass().getClassLoader()); - service.start(); - - server = service.getServerFactory().create(new HttpServerConfiguration.Builder().setHost(HOST).setPort(PORT).setName("test-server").build()); - server.start(); - } - - @After - public void after() throws Exception { - if (server != null) - server.stop(); - - if (service != null) - service.stop(); - - if (schedulerService != null) - schedulerService.stop(); - } - - @Test - // @AgentRunner.TestConfig(verbose = true) - public void httpServiceTest(final MockTracer tracer) throws Exception { - final Response response = Request.Get("http://" + HOST + ":" + PORT + "/").execute(); - assertEquals(response.returnResponse().getStatusLine().getStatusCode(), 503); - assertEquals(1, tracer.finishedSpans().size()); - } -} \ No newline at end of file diff --git a/rule/pom.xml b/rule/pom.xml index 6a2ee32a6..278411863 100644 --- a/rule/pom.xml +++ b/rule/pom.xml @@ -69,7 +69,6 @@ apache-httpclient lettuce mule-4-core - mule-4-http-service mule-4-module-artifact spring-webflux redisson diff --git a/test/mule/mule-4.2.2/pom.xml b/test/mule/mule-4.2.2/pom.xml index b52ec5a87..d6b7a1696 100644 --- a/test/mule/mule-4.2.2/pom.xml +++ b/test/mule/mule-4.2.2/pom.xml @@ -31,7 +31,7 @@ 4.2.2 ${project.basedir}/src/test/mule-home FINE - -Dsa.integration.*.disable -Dsa.integration.mule*.enable -Dsa.integration.grizzly:http-client.enable -Dsa.integration.jdbc.enable + -Dsa.integration.*.disable -Dsa.integration.mule*.enable -Dsa.integration.grizzly:http-server.enable -Dsa.integration.grizzly:http-client.enable -Dsa.integration.jdbc.enable