Skip to content

Commit

Permalink
Revert "fix: fix for Git request parameter problem (#768)" (#769)
Browse files Browse the repository at this point in the history
This reverts commit 55666a6.
  • Loading branch information
wtt40122 authored Jan 3, 2024
1 parent 55666a6 commit ad1cc15
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 34 deletions.
2 changes: 1 addition & 1 deletion jcommon/docean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Based on Java20
* Fully utilized coroutines and ScopeValue
* JVM parameters that need to be added:
--enable-preview --add-modulesjdk.incubator.concurrent -ea --add-opensjava.base/java.lang=ALL-UNNAMED--add-opensjava.base/jdk.internal.misc=ALL-UNNAMED-Dio.netty.tryReflectionSetAccessible=true
--enable-preview--add-modulesjdk.incubator.concurrent-ea--add-opensjava.base/java.lang=ALL-UNNAMED--add-opensjava.base/jdk.internal.misc=ALL-UNNAMED-Dio.netty.tryReflectionSetAccessible=true
* A lightweight microservices development framework. It can be embedded into the Spring framework.
* Features: Compliant with Java standards, lightweight, no unnecessary libraries, low memory footprint, fast service
requests, high maintainability, and supports plugin extensions.
Expand Down
8 changes: 0 additions & 8 deletions jcommon/docean/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@
<target>21</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,8 @@ public void callMethod(MvcContext context, MvcRequest request, MvcResponse respo
Safe.run(() -> {
JsonElement args = getArgs(method, request.getMethod().toLowerCase(Locale.ROOT), request);
context.setParams(args);
Object[] params = new Object[]{null};
if (method.getMethod().getParameterTypes().length == 1 && method.getMethod().getParameterTypes()[0].equals(MvcContext.class)) {
params[0] = context;
} else {
params = methodInvoker.getMethodParams(method.getMethod(), args);
}
Object[] params = methodInvoker.getMethodParams(method.getMethod(), args);
setMvcContext(context, params);
Object data = this.mvcConfig.isUseCglib() ? methodInvoker.invokeFastMethod(method.getObj(), method.getMethod(), params) :
methodInvoker.invokeMethod(method.getObj(), method.getMethod(), params);

Expand Down
17 changes: 6 additions & 11 deletions jcommon/docean/src/main/java/com/xiaomi/youpin/docean/mvc/Get.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.xiaomi.youpin.docean.mvc;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.xiaomi.youpin.docean.anno.RequestParam;
import com.xiaomi.youpin.docean.mvc.httpmethod.HttpMethodUtils;
import io.netty.handler.codec.http.QueryStringDecoder;
Expand All @@ -33,25 +31,22 @@
*/
public abstract class Get {

public static JsonElement getParams(HttpRequestMethod method, String uri) {
public static JsonArray getParams(HttpRequestMethod method, String uri) {
QueryStringDecoder decoder = new QueryStringDecoder(uri);
Map<String, String> params = decoder.parameters().entrySet().stream().collect(Collectors.toMap(it -> it.getKey(), it -> it.getValue().get(0)));

//只有一个参数,并且是MvcContext
if (HttpMethodUtils.paramIsMvcContext(method)) {
JsonObject res = new JsonObject();
params.entrySet().forEach(it-> res.addProperty(it.getKey(),it.getValue()));
return res;
}

JsonArray array = new JsonArray();
HttpMethodUtils.addMvcContext(method, array);
if (null == params) {
return array;
}
Annotation[][] anns = method.getMethod().getParameterAnnotations();
Arrays.stream(anns).forEach(it -> {
if (it.length > 0) {
RequestParam param = getRequestParam(it);
String name = param.value();
if (!params.containsKey(name)) {
array.add("");
// throw new DoceanException("Missing parameter:" + name);
} else {
array.add(params.get(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@
public class HttpMethodUtils {

public static void addMvcContext(HttpRequestMethod method, JsonArray array) {
if (paramIsMvcContext(method)) {
array.add(new JsonObject());
}
}

public static boolean paramIsMvcContext(HttpRequestMethod method) {
Class<?>[] types = method.getMethod().getParameterTypes();
if (types.length > 0 && types[0] == MvcContext.class) {
return true;
array.add(new JsonObject());
}
return false;
}


Expand Down

0 comments on commit ad1cc15

Please sign in to comment.