roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kyle <k...@bridge9.sakura.ne.jp>
Subject Re: NPE on ServletContext#getMimeType(null) with WildFly
Date Mon, 29 Dec 2014 09:29:28 GMT
Hello Glen,

OK, I just filed these issues just now, also my patch is attached to JIRA.

https://issues.apache.org/jira/browse/ROL-2056
https://issues.apache.org/jira/browse/ROL-2057

Thanks.

2014/12/29 17:58、Glen Mazza <glen.mazza@gmail.com> wrote:

> Hi Kyle, thanks very much for your documentation and code change
> assistance, but please enter all code/doc change requests into our JIRA:
> https://issues.apache.org/jira/browse/ROL/ so we don't lose them.  The
> volunteer developers can't always get to Roller immediately, and it's messy
> trying to store code changes via email.
> 
> Thanks,
> Glen
> 
> On Sun, Dec 28, 2014 at 3:39 AM, kyle <kyle@bridge9.sakura.ne.jp> wrote:
> 
>> Hello,
>> 
>> I'm trying to use Roller5.1.1 on WildFly8.2.0.Final,
>> and I got into a problem that seems like dependent on WildFly.
>> 
>> After I finish procedures of official installation guide for JBoss,
>> and I create a new blog, but the blog can't be visible.
>> URLs of the top page or the blog are always returning status 500,
>> and many NPEs are dumped on logs. like this:
>> 
>> <snip>
>> Caused by: java.lang.NullPointerException
>>        at
>> io.undertow.servlet.spec.ServletContextImpl.getMimeType(ServletContextImpl.java:192)
>>        at
>> org.apache.roller.weblogger.ui.rendering.servlets.PageServlet.doGet(PageServlet.java:423)
>> <snip>
>> 
>> It looks like that the cause is came from WildFly implementation of
>> ServletContext.
>> (
>> https://github.com/undertow-io/undertow/blob/master/servlet/src/main/java/io/undertow/servlet/spec/ServletContextImpl.java
>> )
>> It has no null-check of the argument.
>> 
>> So I created a patch for me, so I just contribute this.
>> 
>> And I'm not sure whether this is right solution or not,
>> So if anyone knows better way, I will be glad if you could let me know.
>> 
>> Thanks.
>> 
>> Index:
>> app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
>> IDEA additional info:
>> Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
>> <+>UTF-8
>> ===================================================================
>> ---
>> app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
>>      (revision )
>> +++
>> app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
>>      (revision )
>> @@ -420,13 +420,19 @@
>>         if (StringUtils.isNotEmpty(page.getOutputContentType())) {
>>             contentType = page.getOutputContentType() + "; charset=utf-8";
>>         } else {
>> +            final String defaultContentType = "text/html; charset=utf-8";
>> +            // prevent NPE at ServletContext#getMimeType(null) on some
>> implementations
>> +            if (page.getLink() == null) {
>> +                contentType = defaultContentType;
>> +            } else {
>> -            String mimeType =
>> RollerContext.getServletContext().getMimeType(
>> -                    page.getLink());
>> -            if (mimeType != null) {
>> -                // we found a match ... set the content deviceType
>> -                contentType = mimeType + "; charset=utf-8";
>> -            } else {
>> +                String mimeType =
>> RollerContext.getServletContext().getMimeType(
>> +                        page.getLink());
>> +                if (mimeType != null) {
>> +                    // we found a match ... set the content deviceType
>> +                    contentType = mimeType + "; charset=utf-8";
>> +                } else {
>> -                contentType = "text/html; charset=utf-8";
>> +                    contentType = defaultContentType;
>> +                }
>>             }
>>         }
>> 
>> 


Mime
View raw message