|
47 | 47 | import java.lang.reflect.InvocationTargetException; |
48 | 48 | import java.lang.reflect.Method; |
49 | 49 | import java.lang.reflect.Parameter; |
50 | | -import java.lang.reflect.ParameterizedType; |
51 | 50 | import java.lang.reflect.Type; |
52 | 51 | import java.security.Principal; |
53 | 52 |
|
@@ -126,81 +125,6 @@ private static Logger getLogger() { |
126 | 125 | return LoggerFactory.getLogger(EndpointInvoker.class); |
127 | 126 | } |
128 | 127 |
|
129 | | - private boolean needsFloatToIntCoercion(JsonNode node, Type targetType) { |
130 | | - if (node == null) { |
131 | | - return false; |
132 | | - } |
133 | | - |
134 | | - // Direct number node |
135 | | - if (node.isNumber() && isIntegralType(targetType) |
136 | | - && !node.canConvertToExactIntegral()) { |
137 | | - return true; |
138 | | - } |
139 | | - |
140 | | - // Array node containing floats to be converted to integral types |
141 | | - if (node.isArray() && isIntegralType(targetType)) { |
142 | | - for (JsonNode element : node) { |
143 | | - if (element.isNumber() |
144 | | - && !element.canConvertToExactIntegral()) { |
145 | | - return true; |
146 | | - } |
147 | | - } |
148 | | - } |
149 | | - |
150 | | - // Object node (for Maps and complex objects) |
151 | | - if (node.isObject() && targetType instanceof ParameterizedType) { |
152 | | - Type rawType = ((ParameterizedType) targetType).getRawType(); |
153 | | - if (rawType instanceof Class<?> |
154 | | - && Map.class.isAssignableFrom((Class<?>) rawType)) { |
155 | | - Type[] args = ((ParameterizedType) targetType) |
156 | | - .getActualTypeArguments(); |
157 | | - if (args.length > 1 && isIntegralType(args[1])) { |
158 | | - // Check if any map values need conversion |
159 | | - for (JsonNode value : node) { |
160 | | - if (value.isNumber() |
161 | | - && !value.canConvertToExactIntegral()) { |
162 | | - return true; |
163 | | - } |
164 | | - } |
165 | | - } |
166 | | - } |
167 | | - } |
168 | | - |
169 | | - return false; |
170 | | - } |
171 | | - |
172 | | - private boolean isIntegralType(Type type) { |
173 | | - if (type instanceof Class<?>) { |
174 | | - Class<?> cls = (Class<?>) type; |
175 | | - if (cls.isArray()) { |
176 | | - // Handle array types |
177 | | - return isIntegralType(cls.getComponentType()); |
178 | | - } |
179 | | - return cls == int.class || cls == Integer.class || cls == long.class |
180 | | - || cls == Long.class || cls == short.class |
181 | | - || cls == Short.class || cls == byte.class |
182 | | - || cls == Byte.class || cls == java.math.BigInteger.class; |
183 | | - } else if (type instanceof ParameterizedType) { |
184 | | - Type rawType = ((ParameterizedType) type).getRawType(); |
185 | | - if (rawType instanceof Class<?>) { |
186 | | - Class<?> cls = (Class<?>) rawType; |
187 | | - // Check for collections of integral types |
188 | | - if (Collection.class.isAssignableFrom(cls) |
189 | | - || Map.class.isAssignableFrom(cls)) { |
190 | | - Type[] args = ((ParameterizedType) type) |
191 | | - .getActualTypeArguments(); |
192 | | - if (args.length > 0) { |
193 | | - // For Map, check the value type (args[1]) |
194 | | - int checkIndex = Map.class.isAssignableFrom(cls) |
195 | | - && args.length > 1 ? 1 : 0; |
196 | | - return isIntegralType(args[checkIndex]); |
197 | | - } |
198 | | - } |
199 | | - } |
200 | | - } |
201 | | - return false; |
202 | | - } |
203 | | - |
204 | 128 | /** |
205 | 129 | * Gets the return type of the given method. |
206 | 130 | * |
@@ -418,26 +342,10 @@ private Object[] getVaadinEndpointParameters( |
418 | 342 | Type parameterType = javaParameters[i]; |
419 | 343 | Type incomingType = parameterType; |
420 | 344 | try { |
421 | | - JsonNode parameterNode = requestParameters |
422 | | - .get(parameterNames[i]); |
423 | | - Object parameter; |
424 | | - |
425 | | - // Jackson 3 limitation: TreeTraversingParser doesn't respect |
426 | | - // ACCEPT_FLOAT_AS_INT |
427 | | - // when deserializing from JsonNode. Convert to string for |
428 | | - // numeric coercion. |
429 | | - if (needsFloatToIntCoercion(parameterNode, parameterType)) { |
430 | | - // Convert JsonNode to string to allow float-to-int coercion |
431 | | - parameter = endpointObjectMapper |
432 | | - .readerFor(endpointObjectMapper.getTypeFactory() |
433 | | - .constructType(incomingType)) |
434 | | - .readValue(parameterNode.toString()); |
435 | | - } else { |
436 | | - parameter = endpointObjectMapper |
437 | | - .readerFor(endpointObjectMapper.getTypeFactory() |
438 | | - .constructType(incomingType)) |
439 | | - .readValue(parameterNode); |
440 | | - } |
| 345 | + Object parameter = endpointObjectMapper |
| 346 | + .readerFor(endpointObjectMapper.getTypeFactory() |
| 347 | + .constructType(incomingType)) |
| 348 | + .readValue(requestParameters.get(parameterNames[i])); |
441 | 349 | endpointParameters[i] = parameter; |
442 | 350 |
|
443 | 351 | if (parameter != null) { |
|
0 commit comments