ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From niti...@apache.org
Subject ambari git commit: AMBARI-18584 : Ignoring objects of type InputStream from conversion in GsonJsonProvider. This resolves the bug where in files with extension .json were not uploading (nitirajrathore)
Date Thu, 03 Nov 2016 09:55:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 b9e7df0ed -> 0dd2842be


AMBARI-18584 : Ignoring objects of type InputStream from conversion in GsonJsonProvider. This
resolves the bug where in files with  extension .json were not uploading (nitirajrathore)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0dd2842b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0dd2842b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0dd2842b

Branch: refs/heads/branch-2.5
Commit: 0dd2842be39937b14420b48b5a5f7ebb9ddd5af4
Parents: b9e7df0
Author: Nitiraj Rathore <nitiraj.rathore@gmail.com>
Authored: Thu Nov 3 15:24:39 2016 +0530
Committer: Nitiraj Rathore <nitiraj.rathore@gmail.com>
Committed: Thu Nov 3 15:24:39 2016 +0530

----------------------------------------------------------------------
 .../org/apache/ambari/server/api/GsonJsonProvider.java  | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0dd2842b/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
index 8ba9ff7..e793957 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
@@ -32,7 +32,13 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
@@ -55,6 +61,10 @@ public class GsonJsonProvider implements MessageBodyReader<Object>,
 
   @Override
   public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
+    // ignore objects of type InputStream. Used in case of file uploads
+    if(type.equals(InputStream.class))
+      return entityStream;
+
     Reader reader = new InputStreamReader(entityStream);
     try {
       return gson.fromJson(reader, genericType);


Mime
View raw message