Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D5159200BDB for ; Thu, 3 Nov 2016 16:26:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D3E1C160AFE; Thu, 3 Nov 2016 15:26:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9CDB9160B17 for ; Thu, 3 Nov 2016 16:26:05 +0100 (CET) Received: (qmail 28438 invoked by uid 500); 3 Nov 2016 15:26:04 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 26585 invoked by uid 99); 3 Nov 2016 15:26:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Nov 2016 15:26:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 18BE0F1727; Thu, 3 Nov 2016 15:26:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ncole@apache.org To: commits@ambari.apache.org Date: Thu, 03 Nov 2016 15:26:23 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [22/30] 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) archived-at: Thu, 03 Nov 2016 15:26:07 -0000 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-feature-AMBARI-18634 Commit: f1117c25dcfe1e55e935cf641c1399b12e5846bc Parents: e5a6ee8 Author: Nitiraj Rathore Authored: Thu Nov 3 15:22:54 2016 +0530 Committer: Nitiraj Rathore 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, @Override public Object readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap 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);