You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/07/23 13:06:59 UTC
[cxf] branch master updated: CXF-7802 - URI query parameter without
value causing crash
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new e9a465a CXF-7802 - URI query parameter without value causing crash
e9a465a is described below
commit e9a465ad23018e7ccdba90d74edda9ea5900eea9
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Mon Jul 23 14:06:39 2018 +0100
CXF-7802 - URI query parameter without value causing crash
---
.../org/apache/cxf/jaxrs/utils/InjectionUtils.java | 6 +++---
.../test/java/org/apache/cxf/jaxrs/Customer.java | 5 +++++
.../org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java | 24 ++++++++++++++++++++--
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index 4f1688c..d6b1277 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -121,7 +121,7 @@ public final class InjectionUtils {
// JAX-RS 2.1
STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.sse.Sse");
STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.sse.SseEventSink");
-
+
VALUE_CONTEXTS.add(Application.class.getName());
VALUE_CONTEXTS.add("javax.ws.rs.sse.Sse");
}
@@ -1011,7 +1011,7 @@ public final class InjectionUtils {
Message message) {
//CHECKSTYLE:ON
- if (paramValues == null) {
+ if (paramValues == null || paramValues.size() == 1 && paramValues.get(0) == null) {
if (defaultValue != null) {
paramValues = Collections.singletonList(defaultValue);
} else {
@@ -1515,7 +1515,7 @@ public final class InjectionUtils {
}
}
}
-
+
if (type == null || type == Object.class) {
type = paramCls;
}
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
index 9ead386..fa502ca 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
@@ -212,6 +212,11 @@ public class Customer extends AbstractCustomer implements CustomerInfo {
}
+ public void testGenericObjectParamDefaultValue(@QueryParam("p1") String query1,
+ @QueryParam("p2") @DefaultValue("thequery") String query2) {
+
+ }
+
public void testXmlAdapter(@QueryParam("a")
@XmlJavaTypeAdapter(CustomerBeanAdapter.class)
CustomerBean cb) {
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
index 3604170..d2c9d42 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
@@ -944,13 +944,13 @@ public class JAXRSUtilsTest extends Assert {
assertEquals(2, queryList6.size());
assertEquals(Integer.valueOf(1), queryList6.get(0).get());
assertEquals(Integer.valueOf(2), queryList6.get(1).get());
-
+
List<Integer> queryList7 = (List<Integer>)params.get(7);
assertNotNull(queryList7);
assertEquals(2, queryList7.size());
assertEquals(Long.valueOf(1), queryList7.get(0));
assertEquals(Long.valueOf(2), queryList7.get(1));
-
+
List<Integer> queryList8 = (List<Integer>)params.get(8);
assertNotNull(queryList8);
assertEquals(2, queryList8.size());
@@ -1104,6 +1104,26 @@ public class JAXRSUtilsTest extends Assert {
}
@Test
+ public void testQueryParameterDefaultValue() throws Exception {
+ Message messageImpl = createMessage();
+ ProviderFactory.getInstance(messageImpl).registerUserProvider(
+ new GenericObjectParameterHandler());
+ Class<?>[] argType = {String.class, String.class};
+ Method m = Customer.class.getMethod("testGenericObjectParamDefaultValue", argType);
+
+ messageImpl.put(Message.QUERY_STRING, "p1=thequery&p2");
+ List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
+ new ClassResourceInfo(Customer.class)),
+ null,
+ messageImpl);
+ assertEquals(2, params.size());
+ String query = (String)params.get(0);
+ assertEquals("thequery", query);
+ query = (String)params.get(1);
+ assertEquals("thequery", query);
+ }
+
+ @Test
public void testArrayParamNoProvider() throws Exception {
Message messageImpl = createMessage();
Class<?>[] argType = {String[].class};