Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5FA0DDDA1 for ; Thu, 12 Jul 2012 14:29:18 +0000 (UTC) Received: (qmail 14769 invoked by uid 500); 12 Jul 2012 14:29:18 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 14708 invoked by uid 500); 12 Jul 2012 14:29:18 -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 14699 invoked by uid 99); 12 Jul 2012 14:29:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2012 14:29:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2012 14:29:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F0E6D2388A33; Thu, 12 Jul 2012 14:28:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1360698 - /cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Date: Thu, 12 Jul 2012 14:28:54 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120712142854.F0E6D2388A33@eris.apache.org> Author: dkulp Date: Thu Jul 12 14:28:54 2012 New Revision: 1360698 URL: http://svn.apache.org/viewvc?rev=1360698&view=rev Log: Merged revisions 1360675 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes ........ r1360675 | dkulp | 2012-07-12 09:47:35 -0400 (Thu, 12 Jul 2012) | 10 lines Merged revisions 1360404 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1360404 | dkulp | 2012-07-11 17:15:40 -0400 (Wed, 11 Jul 2012) | 2 lines If using woodstox, don't bother with the pools as they are safe. ........ ........ Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1360698&r1=1360697&r2=1360698&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original) +++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Thu Jul 12 14:28:54 2012 @@ -91,7 +91,9 @@ public final class StaxUtils { private static final Logger LOG = LogUtils.getL7dLogger(StaxUtils.class); private static final BlockingQueue NS_AWARE_INPUT_FACTORY_POOL; + private static final XMLInputFactory SAFE_INPUT_FACTORY; private static final BlockingQueue OUTPUT_FACTORY_POOL; + private static final XMLOutputFactory SAFE_OUTPUT_FACTORY; private static final String XML_NS = "http://www.w3.org/2000/xmlns/"; private static final String DEF_PREFIXES[] = new String[] { @@ -137,8 +139,17 @@ public final class StaxUtils { if (innerElementCountThreshold <= 0) { innerElementCountThreshold = -1; } + XMLInputFactory xif = createXMLInputFactory(true); + if (!xif.getClass().getName().contains("ctc.wstx")) { + xif = null; + } + SAFE_INPUT_FACTORY = xif; - + XMLOutputFactory xof = XMLOutputFactory.newInstance(); + if (!xof.getClass().getName().contains("ctc.wstx")) { + xof = null; + } + SAFE_OUTPUT_FACTORY = xof; } private StaxUtils() { @@ -172,6 +183,9 @@ public final class StaxUtils { * @return */ private static XMLInputFactory getXMLInputFactory() { + if (SAFE_INPUT_FACTORY != null) { + return SAFE_INPUT_FACTORY; + } XMLInputFactory f = NS_AWARE_INPUT_FACTORY_POOL.poll(); if (f == null) { f = createXMLInputFactory(true); @@ -180,10 +194,15 @@ public final class StaxUtils { } private static void returnXMLInputFactory(XMLInputFactory factory) { - NS_AWARE_INPUT_FACTORY_POOL.offer(factory); + if (SAFE_INPUT_FACTORY != factory) { + NS_AWARE_INPUT_FACTORY_POOL.offer(factory); + } } private static XMLOutputFactory getXMLOutputFactory() { + if (SAFE_OUTPUT_FACTORY != null) { + return SAFE_OUTPUT_FACTORY; + } XMLOutputFactory f = OUTPUT_FACTORY_POOL.poll(); if (f == null) { f = XMLOutputFactory.newInstance(); @@ -192,7 +211,9 @@ public final class StaxUtils { } private static void returnXMLOutputFactory(XMLOutputFactory factory) { - OUTPUT_FACTORY_POOL.offer(factory); + if (SAFE_OUTPUT_FACTORY != factory) { + OUTPUT_FACTORY_POOL.offer(factory); + } } /**