Skip to content

Commit f538ad0

Browse files
committed
[agent.java] Add Apache HttpClient 5 dependency and update HttpClient5 implementation
- Add httpclient5 dependency to pom.xml with version 5.2.1 (provided scope) - Update HttpClient5 class to use HttpClient5 API methods (getUri instead of getURI) - Update import statements to use org.apache.hc.client5 package
1 parent b7ef112 commit f538ad0

3 files changed

Lines changed: 27 additions & 21 deletions

File tree

scouter.agent.java/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,12 @@
436436
<version>5.2.1</version>
437437
<scope>provided</scope>
438438
</dependency>
439+
<dependency>
440+
<groupId>org.apache.httpcomponents.client5</groupId>
441+
<artifactId>httpclient5</artifactId>
442+
<version>5.2.1</version>
443+
<scope>provided</scope>
444+
</dependency>
439445
<dependency>
440446
<groupId>com.netflix.ribbon</groupId>
441447
<artifactId>ribbon-loadbalancer</artifactId>

scouter.agent.java/src/main/java/scouter/xtra/httpclient/HttpClient5.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@
1616
*/
1717
package scouter.xtra.httpclient;
1818

19+
import org.apache.hc.client5.http.classic.methods.HttpGet;
20+
import org.apache.hc.client5.http.classic.methods.HttpPut;
21+
import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
1922
import org.apache.hc.core5.http.Header;
2023
import org.apache.hc.core5.http.HttpHost;
2124
import org.apache.hc.core5.http.HttpRequest;
2225
import org.apache.hc.core5.http.HttpResponse;
23-
import org.apache.http.client.methods.HttpGet;
24-
import org.apache.http.client.methods.HttpPut;
25-
import org.apache.http.client.methods.HttpUriRequest;
2626
import scouter.agent.proxy.IHttpClient;
2727

28-
import java.net.URISyntaxException;
29-
3028
public class HttpClient5 implements IHttpClient {
3129
public String getHost(Object o) {
3230
try {
@@ -75,22 +73,23 @@ public int getResponseStatusCode(Object o) {
7573
}
7674

7775
public String getURI(Object o) {
78-
if (o instanceof HttpUriRequest) {
79-
HttpUriRequest req = (HttpUriRequest) o;
80-
return req.getURI().getPath();
81-
} else if (o instanceof HttpGet) {
82-
HttpGet req = (HttpGet) o;
83-
return req.getURI().getPath();
84-
} else if (o instanceof HttpPut) {
85-
HttpPut req = (HttpPut) o;
86-
return req.getURI().getPath();
87-
} else if (o instanceof HttpRequest) {
88-
HttpRequest req = (HttpRequest) o;
89-
try {
76+
try {
77+
HttpUriRequest request;
78+
if (o instanceof HttpUriRequest) {
79+
HttpUriRequest req = (HttpUriRequest) o;
80+
return req.getUri().getPath();
81+
} else if (o instanceof HttpGet) {
82+
HttpGet req = (HttpGet) o;
83+
return req.getUri().getPath();
84+
} else if (o instanceof HttpPut) {
85+
HttpPut req = (HttpPut) o;
86+
return req.getUri().getPath();
87+
} else if (o instanceof HttpRequest) {
88+
HttpRequest req = (HttpRequest) o;
9089
return req.getUri().toString();
91-
} catch (URISyntaxException e) {
92-
return req.toString();
9390
}
91+
} catch (Exception e) {
92+
return o.toString();
9493
}
9594
return o.toString();
9695
}

scouter.common/src/main/java/scouter/util/StrMatch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public COMP getComp() {
144144
}
145145

146146
public static void main(String[] args) {
147-
StrMatch sc = new StrMatch("zepeto.core.api.*Controller.*");
148-
System.out.println(sc.include("zepeto.core.api.sub.UserController.Hello.do()"));
147+
StrMatch sc = new StrMatch("zepeto/core/api/*Controller$*");
148+
System.out.println(sc.include("zepeto/core/api/sub/UserController$getOne$1"));
149+
System.out.println(sc.include("zepeto/core/api/web/module/Refer$Sys"));
149150
}
150151
}

0 commit comments

Comments
 (0)