cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: [CXF-7424] removing the redundant conversion code
Date Thu, 22 Jun 2017 11:09:49 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7d33e713a -> 60a783f6c


[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/60a783f6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/60a783f6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/60a783f6

Branch: refs/heads/3.0.x-fixes
Commit: 60a783f6ccb4bc6801d193b9965cfab8179bb4e6
Parents: ac84efb
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 12:09:34 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/60a783f6/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 6394735..0e7cf2f 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
@@ -95,12 +95,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"

@@ -177,10 +172,6 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
         String enc = mt.getParameters().get("charset");
         return enc == null ? "UTF-8" : enc;
     }
-    private String getCharset(MediaType mt) {
-        return mt.getParameters().get("charset");
-    }
-    
     protected void copyInputToOutput(InputStream is, OutputStream os,
             MultivaluedMap<String, Object> outHeaders) throws IOException {
         if (isRangeSupported()) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/60a783f6/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 87aca72..3c257c1 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