createEchoServer(TestEnvironment environment)
+ throws TTransportException {
+ return AsyncEchoTestServer014.AsyncEchoTestServerFactory.nonblockingServer(environment);
+ }
+
+ @Test
+ public void testSynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getSynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+ @Test
+ public void testAsynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getAsynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+}
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT.java
index b4729312eb00..be0b0b771926 100644
--- a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT.java
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT.java
@@ -18,9 +18,7 @@
import static org.junit.Assert.assertEquals;
-
-import com.navercorp.pinpoint.plugin.thrift.common.client.AsyncEchoTestClient;
-import com.navercorp.pinpoint.plugin.thrift.common.client.SyncEchoTestClient;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
import com.navercorp.pinpoint.test.plugin.ImportPlugin;
@@ -62,7 +60,7 @@ public void testSynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final SyncEchoTestClient client = getServer().getSynchronousClient();
+ final EchoTestClient client = getServer().getSynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
@@ -73,7 +71,7 @@ public void testAsynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final AsyncEchoTestClient client = getServer().getAsynchronousClient();
+ final EchoTestClient client = getServer().getAsynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT014.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT014.java
new file mode 100644
index 000000000000..544dff2dc471
--- /dev/null
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/asynchronous/ThriftThreadedSelectorServerAsyncIT014.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2022 NAVER Corp.
+ *
+ * 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 com.navercorp.pinpoint.plugin.thrift.it.asynchronous;
+
+import com.navercorp.pinpoint.plugin.thrift.common.TestEnvironment;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
+
+import com.navercorp.pinpoint.plugin.thrift.common.server.AsyncEchoTestServer014;
+import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
+import com.navercorp.pinpoint.plugin.thrift.it.EchoTestRunner;
+import com.navercorp.pinpoint.plugin.thrift.it.ThriftVersion;
+import com.navercorp.pinpoint.pluginit.utils.AgentPath;
+import com.navercorp.pinpoint.test.plugin.Dependency;
+import com.navercorp.pinpoint.test.plugin.ImportPlugin;
+import com.navercorp.pinpoint.test.plugin.PinpointAgent;
+import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
+import org.apache.thrift.server.TThreadedSelectorServer;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Integration test for TThreadedSelectorServer with asynchronous processor.
+ *
+ * Tests against libthrift 0.9.2+ due to THRIFT-2274
+ * Tests against libthrift 0.10.0+ (0.9.x -> 0.10.x introduces breaking change to generated thrift code)
+ *
+ * @author HyunGil Jeong
+ */
+@RunWith(PinpointPluginTestSuite.class)
+@PinpointAgent(AgentPath.PATH)
+@Dependency({ ThriftVersion.VERSION_14_16,
+ "org.slf4j:slf4j-simple:1.6.6", "org.slf4j:log4j-over-slf4j:1.6.6", "org.slf4j:slf4j-api:1.6.6" })
+@ImportPlugin({"com.navercorp.pinpoint:pinpoint-thrift-plugin"})
+public class ThriftThreadedSelectorServerAsyncIT014 extends EchoTestRunner> {
+
+ @Override
+ protected ThriftEchoTestServer createEchoServer(TestEnvironment environment)
+ throws TTransportException {
+ return AsyncEchoTestServer014.AsyncEchoTestServerFactory.threadedSelectorServer(environment);
+ }
+
+ @Test
+ public void testSynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getSynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+ @Test
+ public void testAsynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getAsynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+}
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT.java
index d585bc5772fb..bc11e7be3ab6 100644
--- a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT.java
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT.java
@@ -20,6 +20,7 @@
import com.navercorp.pinpoint.plugin.thrift.common.client.AsyncEchoTestClient;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.client.SyncEchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
@@ -61,7 +62,7 @@ public void testSynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final SyncEchoTestClient client = getServer().getSynchronousClient();
+ final EchoTestClient client = getServer().getSynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
@@ -72,7 +73,7 @@ public void testAsynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final AsyncEchoTestClient client = getServer().getAsynchronousClient();
+ final EchoTestClient client = getServer().getAsynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT014.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT014.java
new file mode 100644
index 000000000000..ea893b938f2c
--- /dev/null
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftHalfSyncHalfAsyncServerIT014.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2022 NAVER Corp.
+ *
+ * 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 com.navercorp.pinpoint.plugin.thrift.it.synchronous;
+
+import com.navercorp.pinpoint.plugin.thrift.common.TestEnvironment;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
+
+import com.navercorp.pinpoint.plugin.thrift.common.server.SyncEchoTestServer014;
+import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
+import com.navercorp.pinpoint.plugin.thrift.it.EchoTestRunner;
+import com.navercorp.pinpoint.plugin.thrift.it.ThriftVersion;
+import com.navercorp.pinpoint.pluginit.utils.AgentPath;
+import com.navercorp.pinpoint.test.plugin.Dependency;
+import com.navercorp.pinpoint.test.plugin.ImportPlugin;
+import com.navercorp.pinpoint.test.plugin.PinpointAgent;
+import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
+import org.apache.thrift.server.THsHaServer;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Integration test for THsHaServer with synchronous processor.
+ *
+ * Tests against libthrift 0.9.2+ due to THRIFT-2274
+ * Tests against libthrift 0.10.0+ (0.9.x -> 0.10.x introduces breaking change to generated thrift code)
+ *
+ * @author HyunGil Jeong
+ */
+@RunWith(PinpointPluginTestSuite.class)
+@PinpointAgent(AgentPath.PATH)
+@Dependency({ ThriftVersion.VERSION_14_16,
+ "org.slf4j:slf4j-simple:1.6.6", "org.slf4j:log4j-over-slf4j:1.6.6", "org.slf4j:slf4j-api:1.6.6" })
+@ImportPlugin({"com.navercorp.pinpoint:pinpoint-thrift-plugin"})
+public class ThriftHalfSyncHalfAsyncServerIT014 extends EchoTestRunner> {
+
+ @Override
+ protected ThriftEchoTestServer createEchoServer(TestEnvironment environment) throws TTransportException {
+ return SyncEchoTestServer014.SyncEchoTestServerFactory.halfSyncHalfAsyncServer(environment);
+ }
+
+ @Test
+ public void testSynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getSynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+ @Test
+ public void testAsynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getAsynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+}
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT.java
index 3c2ebcaa3e7e..24c60e6b8927 100644
--- a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT.java
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT.java
@@ -19,6 +19,7 @@
import static org.junit.Assert.assertEquals;
import com.navercorp.pinpoint.plugin.thrift.common.client.AsyncEchoTestClient;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.client.SyncEchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
@@ -61,7 +62,7 @@ public void testSynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final SyncEchoTestClient client = getServer().getSynchronousClient();
+ final EchoTestClient client = getServer().getSynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
@@ -72,7 +73,7 @@ public void testAsynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final AsyncEchoTestClient client = getServer().getAsynchronousClient();
+ final EchoTestClient client = getServer().getAsynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT014.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT014.java
new file mode 100644
index 000000000000..dd30834e180e
--- /dev/null
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftNonblockingServerIT014.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2022 NAVER Corp.
+ *
+ * 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 com.navercorp.pinpoint.plugin.thrift.it.synchronous;
+
+import com.navercorp.pinpoint.plugin.thrift.common.TestEnvironment;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
+import com.navercorp.pinpoint.plugin.thrift.common.server.SyncEchoTestServer014;
+import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
+import com.navercorp.pinpoint.plugin.thrift.it.EchoTestRunner;
+import com.navercorp.pinpoint.plugin.thrift.it.ThriftVersion;
+import com.navercorp.pinpoint.pluginit.utils.AgentPath;
+import com.navercorp.pinpoint.test.plugin.Dependency;
+import com.navercorp.pinpoint.test.plugin.ImportPlugin;
+import com.navercorp.pinpoint.test.plugin.PinpointAgent;
+import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
+import org.apache.thrift.server.TNonblockingServer;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Integration test for TNonblockingServer with synchronous processor.
+ *
+ * Tests against libthrift 0.9.2+ due to THRIFT-2274
+ * Tests against libthrift 0.10.0+ (0.9.x -> 0.10.x introduces breaking change to generated thrift code)
+ *
+ * @author HyunGil Jeong
+ */
+@RunWith(PinpointPluginTestSuite.class)
+@PinpointAgent(AgentPath.PATH)
+@Dependency({ ThriftVersion.VERSION_14_16,
+ "org.slf4j:slf4j-simple:1.6.6", "org.slf4j:log4j-over-slf4j:1.6.6", "org.slf4j:slf4j-api:1.6.6" })
+@ImportPlugin({"com.navercorp.pinpoint:pinpoint-thrift-plugin"})
+public class ThriftNonblockingServerIT014 extends EchoTestRunner> {
+
+ @Override
+ protected ThriftEchoTestServer createEchoServer(TestEnvironment environment)
+ throws TTransportException {
+ return SyncEchoTestServer014.SyncEchoTestServerFactory.nonblockingServer(environment);
+ }
+
+ @Test
+ public void testSynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getSynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+ @Test
+ public void testAsynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getAsynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+}
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftSimpleServerIT.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftSimpleServerIT.java
index 4495d496f198..b84eccc2bdc5 100644
--- a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftSimpleServerIT.java
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftSimpleServerIT.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.*;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.client.SyncEchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
@@ -58,7 +59,7 @@ public void testSynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final SyncEchoTestClient client = getServer().getSynchronousClient();
+ final EchoTestClient client = getServer().getSynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadPoolServerIT.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadPoolServerIT.java
index 700e868d14a5..e07abb0a4c2c 100644
--- a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadPoolServerIT.java
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadPoolServerIT.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertEquals;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.client.SyncEchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
@@ -59,7 +60,7 @@ public void testSynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final SyncEchoTestClient client = getServer().getSynchronousClient();
+ final EchoTestClient client = getServer().getSynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT.java
index 9729d8ddab86..da7554a4807f 100644
--- a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT.java
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT.java
@@ -19,6 +19,7 @@
import static org.junit.Assert.assertEquals;
import com.navercorp.pinpoint.plugin.thrift.common.client.AsyncEchoTestClient;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.client.SyncEchoTestClient;
import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
@@ -61,7 +62,7 @@ public void testSynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final SyncEchoTestClient client = getServer().getSynchronousClient();
+ final EchoTestClient client = getServer().getSynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
@@ -72,7 +73,7 @@ public void testAsynchronousRpcCall() throws Exception {
// Given
final String expectedMessage = "TEST_MESSAGE";
// When
- final AsyncEchoTestClient client = getServer().getAsynchronousClient();
+ final EchoTestClient client = getServer().getAsynchronousClient();
final String result = invokeAndVerify(client, expectedMessage);
// Then
assertEquals(expectedMessage, result);
diff --git a/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT014.java b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT014.java
new file mode 100644
index 000000000000..1619ef803bf3
--- /dev/null
+++ b/plugins-it/thrift-it/src/test/java/com/navercorp/pinpoint/plugin/thrift/it/synchronous/ThriftThreadedSelectorServerIT014.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2022 NAVER Corp.
+ *
+ * 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 com.navercorp.pinpoint.plugin.thrift.it.synchronous;
+
+import com.navercorp.pinpoint.plugin.thrift.common.TestEnvironment;
+import com.navercorp.pinpoint.plugin.thrift.common.client.EchoTestClient;
+
+import com.navercorp.pinpoint.plugin.thrift.common.server.SyncEchoTestServer014;
+import com.navercorp.pinpoint.plugin.thrift.common.server.ThriftEchoTestServer;
+import com.navercorp.pinpoint.plugin.thrift.it.EchoTestRunner;
+import com.navercorp.pinpoint.plugin.thrift.it.ThriftVersion;
+import com.navercorp.pinpoint.pluginit.utils.AgentPath;
+import com.navercorp.pinpoint.test.plugin.Dependency;
+import com.navercorp.pinpoint.test.plugin.ImportPlugin;
+import com.navercorp.pinpoint.test.plugin.PinpointAgent;
+import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
+import org.apache.thrift.server.TThreadedSelectorServer;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Integration test for TThreadedSelectorServer with synchronous processor.
+ *
+ * Tests against libthrift 0.9.2+ due to THRIFT-2274
+ * Tests against libthrift 0.10.0+ (0.9.x -> 0.10.x introduces breaking change to generated thrift code)
+ *
+ * @author HyunGil Jeong
+ */
+@RunWith(PinpointPluginTestSuite.class)
+@PinpointAgent(AgentPath.PATH)
+@Dependency({ ThriftVersion.VERSION_14_16,
+ "org.slf4j:slf4j-simple:1.6.6", "org.slf4j:log4j-over-slf4j:1.6.6", "org.slf4j:slf4j-api:1.6.6" })
+@ImportPlugin({"com.navercorp.pinpoint:pinpoint-thrift-plugin"})
+public class ThriftThreadedSelectorServerIT014 extends EchoTestRunner> {
+
+ @Override
+ protected ThriftEchoTestServer createEchoServer(TestEnvironment environment)
+ throws TTransportException {
+ return SyncEchoTestServer014.SyncEchoTestServerFactory.threadedSelectorServer(environment);
+ }
+
+ @Test
+ public void testSynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getSynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+ @Test
+ public void testAsynchronousRpcCall() throws Exception {
+ // Given
+ final String expectedMessage = "TEST_MESSAGE";
+ // When
+ final EchoTestClient client = getServer().getAsynchronousClient();
+ final String result = invokeAndVerify(client, expectedMessage);
+ // Then
+ assertEquals(expectedMessage, result);
+ }
+
+}
diff --git a/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/ThriftPlugin.java b/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/ThriftPlugin.java
index b9344dd13bd7..d9d7bde84952 100644
--- a/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/ThriftPlugin.java
+++ b/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/ThriftPlugin.java
@@ -49,6 +49,7 @@
import com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.server.TProtocolReadMessageEndInterceptor;
import com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.server.TProtocolReadTTypeInterceptor;
import com.navercorp.pinpoint.plugin.thrift.interceptor.transport.TNonblockingSocketConstructInterceptor;
+import com.navercorp.pinpoint.plugin.thrift.interceptor.transport.TSocketConstructInterceptor;
import java.security.ProtectionDomain;
import java.util.List;
@@ -303,28 +304,37 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, Strin
}
// Common
-
private void addInterceptorsForRetrievingSocketAddresses() {
// injector TTranports
// TSocket(Socket), TSocket(String, int, int)
- addTTransportEditor("org.apache.thrift.transport.TSocket",
- "com.navercorp.pinpoint.plugin.thrift.interceptor.transport.TSocketConstructInterceptor", new String[]{"java.net.Socket"}, new String[]{
- "java.lang.String", "int", "int"});
+ transformTemplate.transform("org.apache.thrift.transport.TSocket", TSocketTransform.class);
// wrapper TTransports
// TFramedTransport(TTransport), TFramedTransport(TTransport, int)
addTTransportEditor("org.apache.thrift.transport.TFramedTransport",
"com.navercorp.pinpoint.plugin.thrift.interceptor.transport.wrapper.TFramedTransportConstructInterceptor",
- new String[]{"org.apache.thrift.transport.TTransport"}, new String[]{"org.apache.thrift.transport.TTransport", "int"});
+ new String[]{"org.apache.thrift.transport.TTransport"},
+ new String[]{"org.apache.thrift.transport.TTransport", "int"});
+ // 0.14
+ addTTransportEditor("org.apache.thrift.transport.layered.TFramedTransport",
+ "com.navercorp.pinpoint.plugin.thrift.interceptor.transport.wrapper.TFramedTransportConstructInterceptor",
+ new String[]{"org.apache.thrift.transport.TTransport", "int"});
+
// TFastFramedTransport(TTransport, int, int)
addTTransportEditor("org.apache.thrift.transport.TFastFramedTransport",
- "com.navercorp.pinpoint.plugin.thrift.interceptor.transport.wrapper.TFastFramedTransportConstructInterceptor", new String[]{
- "org.apache.thrift.transport.TTransport", "int", "int"});
+ "com.navercorp.pinpoint.plugin.thrift.interceptor.transport.wrapper.TFastFramedTransportConstructInterceptor",
+ new String[]{"org.apache.thrift.transport.TTransport", "int", "int"});
+ // 0.14
+ addTTransportEditor("org.apache.thrift.transport.layered.TFastFramedTransport",
+ "com.navercorp.pinpoint.plugin.thrift.interceptor.transport.wrapper.TFastFramedTransportConstructInterceptor",
+ new String[]{"org.apache.thrift.transport.TTransport", "int", "int"});
+
// TSaslClientTransport(TTransport), TSaslClientTransport(SaslClient, TTransport)
addTTransportEditor("org.apache.thrift.transport.TSaslClientTransport",
"com.navercorp.pinpoint.plugin.thrift.interceptor.transport.wrapper.TSaslTransportConstructInterceptor",
- new String[]{"org.apache.thrift.transport.TTransport"}, new String[]{"javax.security.sasl.SaslClient",
- "org.apache.thrift.transport.TTransport"});
+ new String[]{"org.apache.thrift.transport.TTransport"},
+ new String[]{"javax.security.sasl.SaslClient", "org.apache.thrift.transport.TTransport"},
+ new String[]{"java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", "java.util.Map", "javax.security.auth.callback.CallbackHandler", "org.apache.thrift.transport.TTransport"});
// TMemoryInputTransport - simply add socket field
addTTransportEditor("org.apache.thrift.transport.TMemoryInputTransport");
@@ -337,8 +347,34 @@ private void addInterceptorsForRetrievingSocketAddresses() {
addFrameBufferEditor();
}
- // Common - transports
+ public static class TSocketTransform implements TransformCallback {
+
+ @Override
+ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class> classBeingRedefined,
+ ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
+ final InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
+ target.addField(ThriftConstants.FIELD_ACCESSOR_SOCKET);
+ final InstrumentMethod constructorMethod1 = target.getConstructor("java.net.Socket");
+ if (constructorMethod1 != null) {
+ constructorMethod1.addInterceptor(TSocketConstructInterceptor.class);
+ }
+
+ // 0.14 or later
+ InstrumentMethod constructorMethod2 = target.getConstructor("org.apache.thrift.TConfiguration", "java.lang.String", "int", "int");
+ if (constructorMethod2 == null) {
+ // old
+ constructorMethod2 = target.getConstructor("java.lang.String", "int", "int");
+ }
+ if (constructorMethod2 != null) {
+ constructorMethod2.addInterceptor(TSocketConstructInterceptor.class);
+ }
+
+ return target.toBytecode();
+ }
+ }
+
+ // Common - transports
private void addTTransportEditor(String tTransportFqcn) {
final String targetClassName = tTransportFqcn;
transformTemplate.transform(targetClassName, TTransportTransform.class);
@@ -412,15 +448,19 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, Strin
target.addField(ThriftConstants.FIELD_ACCESSOR_SOCKET);
target.addField(ThriftConstants.FIELD_ACCESSOR_SOCKET_ADDRESS);
- // TNonblockingSocket(SocketChannel, int, SocketAddress)
- final InstrumentMethod constructor = target.getConstructor("java.nio.channels.SocketChannel", "int", "java.net.SocketAddress");
+ // 0.14 or later
+ InstrumentMethod constructor = target.getConstructor("org.apache.thrift.TConfiguration", "java.nio.channels.SocketChannel", "int", "java.net.SocketAddress");
+ if (constructor == null) {
+ // old
+ // TNonblockingSocket(SocketChannel, int, SocketAddress)
+ constructor = target.getConstructor("java.nio.channels.SocketChannel", "int", "java.net.SocketAddress");
+ }
if (constructor != null) {
constructor.addInterceptor(TNonblockingSocketConstructInterceptor.class);
}
return target.toBytecode();
}
-
}
private void addFrameBufferEditor() {
diff --git a/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/interceptor/transport/TNonblockingSocketConstructInterceptor.java b/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/interceptor/transport/TNonblockingSocketConstructInterceptor.java
index a0e5968f9fe4..461b61bef6a9 100644
--- a/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/interceptor/transport/TNonblockingSocketConstructInterceptor.java
+++ b/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/interceptor/transport/TNonblockingSocketConstructInterceptor.java
@@ -19,6 +19,7 @@
import java.net.Socket;
import java.net.SocketAddress;
+import com.navercorp.pinpoint.common.util.ArrayArgumentUtils;
import com.navercorp.pinpoint.common.util.ArrayUtils;
import org.apache.thrift.transport.TNonblockingSocket;
@@ -46,36 +47,34 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
- if (validate(target, args)) {
- Socket socket = ((TNonblockingSocket)target).getSocketChannel().socket();
- ((SocketFieldAccessor)target)._$PINPOINT$_setSocket(socket);
- if (args[2] instanceof SocketAddress) {
- SocketAddress socketAddress = (SocketAddress)args[2];
- ((SocketAddressFieldAccessor)target)._$PINPOINT$_setSocketAddress(socketAddress);
+ if (validate(target)) {
+ final Socket socket = ((TNonblockingSocket) target).getSocketChannel().socket();
+ ((SocketFieldAccessor) target)._$PINPOINT$_setSocket(socket);
+
+ SocketAddress socketAddress = ArrayArgumentUtils.getArgument(args, 2, SocketAddress.class);
+ if (socketAddress == null) {
+ socketAddress = ArrayArgumentUtils.getArgument(args, 3, SocketAddress.class);
+ }
+ if (socketAddress == null) {
+ logger.info("Unexpected arguments. arg[2] or arg[3] is a SocketAddress class. args={}", args);
+ return;
}
+ ((SocketAddressFieldAccessor) target)._$PINPOINT$_setSocketAddress(socketAddress);
}
}
- private boolean validate(Object target, Object[] args) {
+ private boolean validate(Object target) {
if (!(target instanceof TNonblockingSocket)) {
return false;
}
- if (ArrayUtils.getLength(args) != 3) {
- return false;
- }
if (!(target instanceof SocketFieldAccessor)) {
- if (isDebug) {
- logger.debug("Invalid target object. Need field accessor({}).", SocketFieldAccessor.class.getName());
- }
+ logger.info("Invalid target object. Need field accessor({}).", SocketFieldAccessor.class.getName());
return false;
}
if (!(target instanceof SocketAddressFieldAccessor)) {
- if (isDebug) {
- logger.debug("Invalid target object. Need field accessor({}).", SocketAddressFieldAccessor.class.getName());
- }
+ logger.info("Invalid target object. Need field accessor({}).", SocketAddressFieldAccessor.class.getName());
return false;
}
return true;
}
-
}