Commits

Anonymous committed 3a80e2c

Avoiding NullPointerException by null charsetName
Submitted by: Lars Torunski

Comments (0)

Files changed (1)

src/core/java/com/opensymphony/oscache/web/filter/CacheHttpServletResponseWrapper.java

      */
     public PrintWriter getWriter() throws IOException {
         if (cachedWriter == null) {
-            cachedWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), result.getContentEncoding()));
+            String encoding = result.getContentEncoding();
+            if (encoding != null) {
+                cachedWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), encoding));
+            } else { // using the default character encoding
+                cachedWriter = new PrintWriter(new OutputStreamWriter(getOutputStream()));
+            }
         }
 
         return cachedWriter;