[
https://issues.apache.org/jira/browse/CXF-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andreas Sahlbach closed CXF-3255.
---------------------------------
Resolution: Not A Problem
already fixed. just saw the fix in the trunk (and my example source) after I
reported the bug. hehe...just a few seconds too late. never mind.
> Possible NullPointerException while processing Form Parameters
> --------------------------------------------------------------
>
> Key: CXF-3255
> URL: https://issues.apache.org/jira/browse/CXF-3255
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.3.1
> Reporter: Andreas Sahlbach
>
> From the current trunk state:
> ----
> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>
> {code}
> private static Object processFormParam(Message m, String key,
> Class<?> pClass, Type genericType,
> String defaultValue,
> boolean decode) {
>
> MessageContext mc = new MessageContextImpl(m);
> MediaType mt = mc.getHttpHeaders().getMediaType();
>
> @SuppressWarnings("unchecked")
> MultivaluedMap<String, String> params = (MultivaluedMap<String,
> String>)m.get(FORM_PARAM_MAP);
>
> if (params == null) {
> params = new MetadataMap<String, String>();
> m.put(FORM_PARAM_MAP, params);
>
> if (mt == null ||
> mt.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
> String body =
> (String)m.get("org.apache.cxf.jaxrs.provider.form.body");
> if (body == null) {
> body =
> FormUtils.readBody(m.getContent(InputStream.class), mt);
> // <---------------- mt can be null
> m.put("org.apache.cxf.jaxrs.provider.form.body", body);
> }
> {code}
> ----
> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
> {code}
> public static String readBody(InputStream is, MediaType mt) {
> try {
> ByteArrayOutputStream bos = new ByteArrayOutputStream();
> IOUtils.copy(is, bos, 1024);
> return new String(bos.toByteArray(), getCharset(mt));
> // <----------------- mt can be null (see above)
> } catch (Exception ex) {
> throw new WebApplicationException(ex);
> }
> }
>
> private static String getCharset(MediaType mt) {
> String charset = mt == null ? "UTF-8" :
> mt.getParameters().get("charset"); // <----------------- NPE if mt == null
> return charset == null ? "UTF-8" : charset;
> }
> {code}
> Not sure how often it happens. But there is at least one dump user that was
> able to do it and I am proud to be this user. :-)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.