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 CF99E200CB3 for ; Mon, 26 Jun 2017 13:31:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CE307160BD9; Mon, 26 Jun 2017 11:31:44 +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 20E4B160BDE for ; Mon, 26 Jun 2017 13:31:43 +0200 (CEST) Received: (qmail 35386 invoked by uid 500); 26 Jun 2017 11:31:43 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 35377 invoked by uid 99); 26 Jun 2017 11:31:43 -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; Mon, 26 Jun 2017 11:31:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1CD00E00B3; Mon, 26 Jun 2017 11:31:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: <50cb76ca0436404a9b5026b733354a2f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: [CXF-7429] Preventing NPE Date: Mon, 26 Jun 2017 11:31:42 +0000 (UTC) archived-at: Mon, 26 Jun 2017 11:31:45 -0000 Repository: cxf Updated Branches: refs/heads/3.1.x-fixes 4ae1b339d -> 5585ad569 [CXF-7429] Preventing NPE Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5585ad56 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5585ad56 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5585ad56 Branch: refs/heads/3.1.x-fixes Commit: 5585ad5691fbbe8cb0f74f3ebf670edd4a2eecc8 Parents: 4ae1b33 Author: Sergey Beryozkin Authored: Mon Jun 26 12:06:55 2017 +0100 Committer: Sergey Beryozkin Committed: Mon Jun 26 12:31:21 2017 +0100 ---------------------------------------------------------------------- .../cxf/jaxrs/impl/WriterInterceptorMBW.java | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/5585ad56/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java index 053ac69..dfa02a6 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java @@ -57,11 +57,6 @@ public class WriterInterceptorMBW implements WriterInterceptor { @SuppressWarnings("unchecked") @Override public void aroundWriteTo(WriterInterceptorContext c) throws IOException, WebApplicationException { - - if (LOG.isLoggable(Level.FINE)) { - LOG.fine("Response EntityProvider is: " + writer.getClass().getName()); - } - MultivaluedMap headers = c.getHeaders(); Object mtObject = headers.getFirst(HttpHeaders.CONTENT_TYPE); MediaType entityMt = mtObject == null ? c.getMediaType() : JAXRSUtils.toMediaType(mtObject.toString()); @@ -77,21 +72,26 @@ public class WriterInterceptorMBW implements WriterInterceptor { writer = (MessageBodyWriter)ProviderFactory.getInstance(m) .createMessageBodyWriter(entityCls, entityType, entityAnns, entityMt, m); - if (writer == null) { - String errorMessage = JAXRSUtils.logMessageHandlerProblem("NO_MSG_WRITER", entityCls, entityMt); - throw new ProcessingException(errorMessage); - } + } + + if (writer == null) { + String errorMessage = JAXRSUtils.logMessageHandlerProblem("NO_MSG_WRITER", entityCls, entityMt); + throw new ProcessingException(errorMessage); } HttpUtils.convertHeaderValuesToString(headers, true); + + if (LOG.isLoggable(Level.FINE)) { + LOG.fine("Response EntityProvider is: " + writer.getClass().getName()); + } - writer.writeTo(c.getEntity(), - c.getType(), - c.getGenericType(), - c.getAnnotations(), - entityMt, - headers, - c.getOutputStream()); + writer.writeTo(c.getEntity(), + c.getType(), + c.getGenericType(), + c.getAnnotations(), + entityMt, + headers, + c.getOutputStream()); }