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 64D38200C7D for ; Mon, 17 Apr 2017 00:32:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 63744160BB0; Sun, 16 Apr 2017 22:32:01 +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 03017160BB5 for ; Mon, 17 Apr 2017 00:31:59 +0200 (CEST) Received: (qmail 82871 invoked by uid 500); 16 Apr 2017 22:31:57 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 79343 invoked by uid 99); 16 Apr 2017 22:31:54 -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; Sun, 16 Apr 2017 22:31:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5CE71DFFAB; Sun, 16 Apr 2017 22:31:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cdutz@apache.org To: commits@flex.apache.org Date: Sun, 16 Apr 2017 22:32:57 -0000 Message-Id: <848188e7f92e4493a5ada63bb05ddd0a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [66/72] [abbrv] flex-blazeds git commit: - Fixed some SonarQube findings archived-at: Sun, 16 Apr 2017 22:32:01 -0000 - Fixed some SonarQube findings Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/1a2c89d4 Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/1a2c89d4 Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/1a2c89d4 Branch: refs/heads/master Commit: 1a2c89d424d132b4bb1703412f91321e3a158880 Parents: 9f2a242 Author: Christofer Dutz Authored: Mon Feb 27 19:23:46 2017 +0100 Committer: Christofer Dutz Committed: Mon Feb 27 19:23:46 2017 +0100 ---------------------------------------------------------------------- .../config/FlexConfigurationManager.java | 166 ++-- .../config/ServerConfigurationParser.java | 939 ++++++------------- .../ClassDeserializationValidator.java | 1 + pom.xml | 6 +- 4 files changed, 367 insertions(+), 745 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/1a2c89d4/core/src/main/java/flex/messaging/config/FlexConfigurationManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/flex/messaging/config/FlexConfigurationManager.java b/core/src/main/java/flex/messaging/config/FlexConfigurationManager.java index 480b122..be1e769 100644 --- a/core/src/main/java/flex/messaging/config/FlexConfigurationManager.java +++ b/core/src/main/java/flex/messaging/config/FlexConfigurationManager.java @@ -17,8 +17,8 @@ package flex.messaging.config; import flex.messaging.LocalizedException; -import flex.messaging.util.Trace; import flex.messaging.util.ClassUtil; +import flex.messaging.util.Trace; import javax.servlet.ServletConfig; import java.io.File; @@ -40,22 +40,18 @@ import java.io.File; *

* * @see ConfigurationParser - * */ -public class FlexConfigurationManager implements ConfigurationManager -{ +public class FlexConfigurationManager implements ConfigurationManager { private static final String DEFAULT_CONFIG_PATH = "/WEB-INF/flex/services-config.xml"; private String configurationPath = null; private ConfigurationFileResolver configurationResolver = null; private ConfigurationParser parser = null; - public MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig) - { + public MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig) { MessagingConfiguration config = new MessagingConfiguration(); - if (servletConfig != null) - { + if (servletConfig != null) { String serverInfo = servletConfig.getServletContext().getServerInfo(); config.getSecuritySettings().setServerInfo(serverInfo); } @@ -64,8 +60,7 @@ public class FlexConfigurationManager implements ConfigurationManager parser = getConfigurationParser(servletConfig); - if (parser == null) - { + if (parser == null) { // "Unable to create a parser to load messaging configuration." LocalizedException lme = new LocalizedException(); lme.setMessage(10138); @@ -75,41 +70,32 @@ public class FlexConfigurationManager implements ConfigurationManager setupConfigurationPathAndResolver(servletConfig); parser.parse(configurationPath, configurationResolver, config); - if (servletConfig != null) - { + if (servletConfig != null) { config.getSystemSettings().setPaths(servletConfig.getServletContext()); } return config; } - public void reportTokens() - { + public void reportTokens() { parser.reportTokens(); } - private ConfigurationParser getConfigurationParser(ServletConfig servletConfig) - { + private ConfigurationParser getConfigurationParser(ServletConfig servletConfig) { ConfigurationParser parser = null; Class parserClass; String className = null; // Check for Custom Parser Specification - if (servletConfig != null) - { + if (servletConfig != null) { String p = servletConfig.getInitParameter("services.configuration.parser"); - if (p != null) - { + if (p != null) { className = p.trim(); - try - { + try { parserClass = ClassUtil.createClass(className); - parser = (ConfigurationParser)parserClass.newInstance(); - } - catch (Throwable t) - { - if (Trace.config) - { + parser = (ConfigurationParser) parserClass.newInstance(); + } catch (Throwable t) { + if (Trace.config) { Trace.trace("Could not load configuration parser as: " + className); } } @@ -118,47 +104,36 @@ public class FlexConfigurationManager implements ConfigurationManager // Always try Sun JRE 1.4 / Apache Xalan Based Implementation first to // avoid performance problems with Sun JRE 1.5 Based Implementation - if (parser == null) - { - try - { + if (parser == null) { + try { ClassUtil.createClass("org.apache.xpath.CachedXPathAPI"); className = "flex.messaging.config.ApacheXPathServerConfigurationParser"; parserClass = ClassUtil.createClass(className); - parser = (ConfigurationParser)parserClass.newInstance(); - } - catch (Throwable t) - { - if (Trace.config) - { + parser = (ConfigurationParser) parserClass.newInstance(); + } catch (Throwable t) { + if (Trace.config) { Trace.trace("Could not load configuration parser as: " + className); } } } // Try Sun JRE 1.5 Based Implementation - if (parser == null) - { - try - { + if (parser == null) { + try { className = "flex.messaging.config.XPathServerConfigurationParser"; parserClass = ClassUtil.createClass(className); // double-check, on some systems the above loads but the import classes don't ClassUtil.createClass("javax.xml.xpath.XPathExpressionException"); - parser = (ConfigurationParser)parserClass.newInstance(); - } - catch (Throwable t) - { - if (Trace.config) - { + parser = (ConfigurationParser) parserClass.newInstance(); + } catch (Throwable t) { + if (Trace.config) { Trace.trace("Could not load configuration parser as: " + className); } } } - if (Trace.config && parser != null) - { + if (Trace.config && parser != null) { Trace.trace("Services Configuration Parser: " + parser.getClass().getName()); } @@ -171,28 +146,23 @@ public class FlexConfigurationManager implements ConfigurationManager * If an entry is specified for windows starting with '/', it's assumed to be in the web application. * If an entry is specified for windows not starting with '\', it's assumed to be on the local file system. * If an entry is specified for non-windows starting with '/', we will first look in the web application - * then the the local file system. + * then the the local file system. * * @param servletConfig configuration */ - private void setupConfigurationPathAndResolver(ServletConfig servletConfig) - { - if (servletConfig != null) - { + private void setupConfigurationPathAndResolver(ServletConfig servletConfig) { + if (servletConfig != null) { String p = servletConfig.getInitParameter("services.configuration.file"); - if ((p == null) || (p.trim().length() == 0)) - { + if ((p == null) || (p.trim().length() == 0)) { // no entry specified in web.xml, always use default and ServletResourceResolver configurationPath = DEFAULT_CONFIG_PATH; configurationResolver = new ServletResourceResolver(servletConfig.getServletContext()); - } - else - { + } else { // an entry was specified in web.xml, configurationPath = p.trim(); // If the uri starts with "classpath:" we need to use a different resolver. - if(configurationPath.startsWith("classpath:")) { + if (configurationPath.startsWith("classpath:")) { configurationResolver = new ClasspathResourceResolver(); } else { // on windows, all paths starting with '/' should be available via the servlet resource resolver @@ -219,20 +189,17 @@ public class FlexConfigurationManager implements ConfigurationManager } // no entry specified in web.xml - else - { - ConfigurationException ce = new ConfigurationException(); + else { + ConfigurationException ce = new ConfigurationException(); ce.setMessage("missing ServletConfig object"); throw ce; } - } + } - private void verifyMinimumJavaVersion() throws ConfigurationException - { - try - { + private void verifyMinimumJavaVersion() throws ConfigurationException { + try { boolean minimum = false; String version = System.getProperty("java.version"); String vendor = System.getProperty("java.vendor"); @@ -242,37 +209,24 @@ public class FlexConfigurationManager implements ConfigurationManager String[] split = version.split(":"); int first = Integer.parseInt(split[0]); - if (first > 1) - { + if (first > 1) { minimum = true; - } - else if (first == 1) - { + } else if (first == 1) { int second = Integer.parseInt(split[1]); - if (second > 4) - { + if (second > 4) { minimum = true; - } - else if (second == 4) - { + } else if (second == 4) { int third = Integer.parseInt(split[2]); - if (third > 2) - { + if (third > 2) { minimum = true; - } - else if (third == 2) - { - if ((vendor != null) && vendor.contains("Sun")) - { + } else if (third == 2) { + if ((vendor != null) && vendor.contains("Sun")) { // test at least 1.4.2_06 on Sun int fourth = Integer.parseInt(split[3]); - if (fourth >= 6) - { + if (fourth >= 6) { minimum = true; } - } - else - { + } else { // test at least 1.4.2 on non-Sun minimum = true; } @@ -280,34 +234,24 @@ public class FlexConfigurationManager implements ConfigurationManager } } - if (!minimum) - { + if (!minimum) { ConfigurationException cx = new ConfigurationException(); - if ((vendor != null) && vendor.contains("Sun")) - { + if ((vendor != null) && vendor.contains("Sun")) { // The minimum required Java version was not found. Please install JDK 1.4.2_06 or above. Current version is XX. - cx.setMessage(10139, new Object[] { System.getProperty("java.version")}); - } - else - { + cx.setMessage(10139, new Object[]{System.getProperty("java.version")}); + } else { // The minimum required Java version was not found. Please install JDK 1.4.2 or above. Current version is XX. - cx.setMessage(10140, new Object[] { System.getProperty("java.version")}); + cx.setMessage(10140, new Object[]{System.getProperty("java.version")}); } throw cx; } - } - catch (Throwable t) - { - if (t instanceof ConfigurationException) - { - throw ((ConfigurationException)t); - } - else - { - if (Trace.config) - { + } catch (Throwable t) { + if (t instanceof ConfigurationException) { + throw ((ConfigurationException) t); + } else { + if (Trace.config) { Trace.trace("Could not verified required java version. version=" + System.getProperty("java.version")); } }