cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7424] removing the redundant conversion code
Date Thu, 22 Jun 2017 11:08:48 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 776264dde -> df314e5d9


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

Branch: refs/heads/3.1.x-fixes
Commit: df314e5d9047b0903b9e7d0bf4c8af146c1be73c
Parents: 776264d
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:08:33 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/df314e5d/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 bb48362..39103b7 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"

@@ -179,10 +174,6 @@ 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,
             MultivaluedMap<String, Object> outHeaders) throws IOException {
         if (isRangeSupported()) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/df314e5d/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