cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [2/2] cxf git commit: [CXF-7424] removing the redundant conversion code
Date Thu, 22 Jun 2017 10:54:45 GMT
[CXF-7424] removing the redundant conversion code


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2dc6d056
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2dc6d056
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2dc6d056

Branch: refs/heads/master
Commit: 2dc6d0569511332af00180390fd31b9c9b47f798
Parents: f5e8457
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Jun 22 11:54:24 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Jun 22 11:54:24 2017 +0100

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/provider/BinaryDataProvider.java    | 11 ++---------
 .../cxf/jaxrs/provider/BinaryDataProviderTest.java       |  8 +-------
 2 files changed, 3 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/2dc6d056/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
index 0abfd4b..c08df4e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
@@ -107,12 +107,7 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
                 return clazz.cast(new InputStreamReader(is, getEncoding(type)));
             }
             if (byte[].class.isAssignableFrom(clazz)) {
-                String enc = getCharset(type);
-                if (enc == null) {
-                    return clazz.cast(IOUtils.readBytesFromStream(is));
-                } else {
-                    return clazz.cast(IOUtils.toString(is, bufferSize, enc).getBytes(enc));
-                }
+                return clazz.cast(IOUtils.readBytesFromStream(is));
             }
             if (File.class.isAssignableFrom(clazz)) {
                 LOG.warning("Reading data into File objects with the help of pre-packaged"
@@ -191,9 +186,7 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
         String enc = mt.getParameters().get("charset");
         return enc == null ? StandardCharsets.UTF_8.name() : enc;
     }
-    private String getCharset(MediaType mt) {
-        return mt.getParameters().get("charset");
-    }
+    
 
     protected void copyInputToOutput(InputStream is, OutputStream os,
             Annotation[] anns, MultivaluedMap<String, Object> outHeaders) throws IOException
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/2dc6d056/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
index f67e0fd..10da4df 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
@@ -100,18 +100,12 @@ public class BinaryDataProviderTest extends Assert {
     @Test
     public void testReadBytesFromUtf8() throws Exception {
         MessageBodyReader p = new BinaryDataProvider();
-        byte[] utf8Bytes = "世界ーファイル".getBytes("UTF-8");
+        byte[] utf8Bytes = "世界ーファイル".getBytes("UTF-16");
         byte[] readBytes = (byte[])p.readFrom(byte[].class, byte[].class, new Annotation[]{},
                                           MediaType.APPLICATION_OCTET_STREAM_TYPE,
                                           new MetadataMap<String, Object>(),
                                           new ByteArrayInputStream(utf8Bytes));
         assertTrue(Arrays.equals(utf8Bytes, readBytes));
-
-        readBytes = (byte[])p.readFrom(byte[].class, byte[].class, new Annotation[]{},
-                                              MediaType.valueOf("application/octet-stream;charset=UTF-8"),
-                                              new MetadataMap<String, Object>(),
-                                              new ByteArrayInputStream(utf8Bytes));
-        assertTrue(Arrays.equals(utf8Bytes, readBytes));
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })


Mime
View raw message