ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [24/50] [abbrv] 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 Fri, 04 Nov 2016 16:55:05 GMT
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/f1117c25
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f1117c25
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f1117c25

Branch: refs/heads/branch-dev-patch-upgrade
Commit: f1117c25dcfe1e55e935cf641c1399b12e5846bc
Parents: e5a6ee8
Author: Nitiraj Rathore <nitiraj.rathore@gmail.com>
Authored: Thu Nov 3 15:22:54 2016 +0530
Committer: Nitiraj Rathore <nitiraj.rathore@gmail.com>
Committed: Thu Nov 3 15:22:54 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/f1117c25/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