-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#11005] Update getMethod compatibility of spring-webflux
- Loading branch information
1 parent
579b8f5
commit 9a66857
Showing
9 changed files
with
188 additions
and
6 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
agent-module/plugins/spring-stub/src/main/java/org/springframework/http/HttpRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 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 org.springframework.http; | ||
|
||
import java.net.URI; | ||
|
||
// Stub | ||
public interface HttpRequest extends HttpMessage { | ||
|
||
HttpMethod getMethod(); | ||
|
||
URI getURI(); | ||
|
||
// Deleted from version of spring 6.1 | ||
String getMethodValue(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ava/com/navercorp/pinpoint/plugin/spring/webflux/interceptor/util/HttpMethodProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2024 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.spring.webflux.interceptor.util; | ||
|
||
public interface HttpMethodProvider { | ||
String getMethod(Object target); | ||
} |
35 changes: 35 additions & 0 deletions
35
.../navercorp/pinpoint/plugin/spring/webflux/interceptor/util/HttpMethodProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2024 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.spring.webflux.interceptor.util; | ||
|
||
import com.navercorp.pinpoint.plugin.spring.webflux.SpringVersion; | ||
|
||
public class HttpMethodProviderFactory { | ||
|
||
public HttpMethodProviderFactory() { | ||
} | ||
|
||
public static HttpMethodProvider getHttpMethodProvider(int version) { | ||
switch (version) { | ||
case SpringVersion.SPRING_VERSION_5: | ||
return new Spring5HttpMethodProvider(); | ||
case SpringVersion.SPRING_VERSION_6: | ||
return new Spring6HttpMethodProvider(); | ||
default: | ||
return new UnsupportedHttpMethodProvider(); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../navercorp/pinpoint/plugin/spring/webflux/interceptor/util/Spring5HttpMethodProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 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.spring.webflux.interceptor.util; | ||
|
||
import org.springframework.http.HttpRequest; | ||
|
||
public class Spring5HttpMethodProvider implements HttpMethodProvider { | ||
@Override | ||
public String getMethod(Object target) { | ||
if (target instanceof HttpRequest) { | ||
final HttpRequest request = (HttpRequest) target; | ||
try { | ||
return request.getMethodValue(); | ||
} catch (Exception ignored) { | ||
} | ||
} | ||
return null; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../navercorp/pinpoint/plugin/spring/webflux/interceptor/util/Spring6HttpMethodProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 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.spring.webflux.interceptor.util; | ||
|
||
import org.springframework.http.HttpRequest; | ||
|
||
public class Spring6HttpMethodProvider implements HttpMethodProvider { | ||
@Override | ||
public String getMethod(Object target) { | ||
if (target instanceof HttpRequest) { | ||
final HttpRequest request = (HttpRequest) target; | ||
try { | ||
return request.getMethod().name(); | ||
} catch (Exception ignored) { | ||
} | ||
} | ||
return null; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ercorp/pinpoint/plugin/spring/webflux/interceptor/util/UnsupportedHttpMethodProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2024 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.spring.webflux.interceptor.util; | ||
|
||
public class UnsupportedHttpMethodProvider implements HttpMethodProvider { | ||
@Override | ||
public String getMethod(Object target) { | ||
return null; | ||
} | ||
} |