wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r820513 - /incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/StringProvider.java
Date Thu, 01 Oct 2009 02:57:22 GMT
Author: bluk
Date: Thu Oct  1 02:57:21 2009
New Revision: 820513

URL: http://svn.apache.org/viewvc?rev=820513&view=rev
Log:
Fix StringProvider getSize when different charset

String provider returning wrong length when
a particular character set is used.

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/StringProvider.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/StringProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/StringProvider.java?rev=820513&r1=820512&r2=820513&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/StringProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/StringProvider.java
Thu Oct  1 02:57:21 2009
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
@@ -67,6 +68,15 @@
                         Type genericType,
                         Annotation[] annotations,
                         MediaType mediaType) {
+        String charSet = ProviderUtils.getCharset(mediaType);
+        if (charSet != null && !"UTF-8".equals(charSet)) {
+            try {
+                return t.getBytes(charSet).length;
+            } catch (UnsupportedEncodingException e) {
+                logger.debug("Unsupported character encoding exception: {}", e);
+                throw new WebApplicationException(e, 500);
+            }
+        }
         return t.length();
     }
 



Mime
View raw message