From 951588a6123cdd9e5091080dcda666fa428a6da9 Mon Sep 17 00:00:00 2001 From: Olga Maciaszek-Sharma Date: Thu, 13 Mar 2025 13:25:27 +0100 Subject: [PATCH] Merge remote-tracking branch 'origin/4.2.x' # Conflicts: # pom.xml --- .../cloud/openfeign/support/SpringMvcContract.java | 7 +++++-- .../openfeign/support/SpringMvcContractTests.java | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java index 9d9d7a8c..5bf64653 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2024 the original author or authors. + * Copyright 2013-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -369,7 +369,10 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource data.template().query(resolve(nameValueResolver.getName()), resolve(nameValueResolver.getValue())); } else { - throw new IllegalArgumentException("Negated params are not supported: " + param); + if (LOG.isDebugEnabled()) { + LOG.debug("Negated params are not supported by Feign and ignored during parameter processing: " + + param); + } } } } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java index 02219e2c..0266a5ec 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2024 the original author or authors. + * Copyright 2013-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,6 +68,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; import static feign.CollectionFormat.CSV; import static feign.CollectionFormat.SSV; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.jupiter.api.Assumptions.assumeTrue; @@ -509,11 +510,11 @@ class SpringMvcContractTests { } @Test - void testProcessAnnotations_ParseParams_NotEqualParams() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> { - Method method = TestTemplate_ParseParams.class.getDeclaredMethod("notEqualParams"); + void testProcessAnnotations_ParseParams_NegatedParams() { + assertThatCode(() -> { + Method method = TestTemplate_ParseParams.class.getDeclaredMethod("negatedParams"); contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - }); + }).doesNotThrowAnyException(); } @Test @@ -831,7 +832,7 @@ class SpringMvcContractTests { ResponseEntity mixParams(); @GetMapping(value = "test", params = { "p1!=1" }) - ResponseEntity notEqualParams(); + ResponseEntity negatedParams(); @GetMapping(value = "test", params = { "p1=1" }) ResponseEntity paramsAndRequestParam(@RequestParam("p2") String p2);