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 3C7DC200C2C for ; Fri, 17 Feb 2017 00:06:30 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3B123160B6F; Thu, 16 Feb 2017 23:06:30 +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 5F5D5160B61 for ; Fri, 17 Feb 2017 00:06:29 +0100 (CET) Received: (qmail 53080 invoked by uid 500); 16 Feb 2017 23:06:28 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 53071 invoked by uid 99); 16 Feb 2017 23:06:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 23:06:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 2216FC05CB for ; Thu, 16 Feb 2017 23:06:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 52N8kAlccXWg for ; Thu, 16 Feb 2017 23:06:26 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id DD6E95F5D3 for ; Thu, 16 Feb 2017 23:06:25 +0000 (UTC) Received: (qmail 53040 invoked by uid 99); 16 Feb 2017 23:06:25 -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, 16 Feb 2017 23:06:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 01B8ADFC1C; Thu, 16 Feb 2017 23:06:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ddekany@apache.org To: notifications@freemarker.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-freemarker git commit: Initialization should fail if UnsafeMethods can't be read. Date: Thu, 16 Feb 2017 23:06:25 +0000 (UTC) archived-at: Thu, 16 Feb 2017 23:06:30 -0000 Repository: incubator-freemarker Updated Branches: refs/heads/2.3-gae 3c0f1903a -> f188f9729 Initialization should fail if UnsafeMethods can't be read. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/f188f972 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/f188f972 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/f188f972 Branch: refs/heads/2.3-gae Commit: f188f97296f2925fd3bf38275af483555b5bac83 Parents: 3c0f190 Author: ddekany Authored: Fri Feb 17 00:06:14 2017 +0100 Committer: ddekany Committed: Fri Feb 17 00:06:14 2017 +0100 ---------------------------------------------------------------------- .../freemarker/ext/beans/UnsafeMethods.java | 51 ++++++++++---------- 1 file changed, 26 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f188f972/src/main/java/freemarker/ext/beans/UnsafeMethods.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/ext/beans/UnsafeMethods.java b/src/main/java/freemarker/ext/beans/UnsafeMethods.java index 6d398ec..5ed3877 100644 --- a/src/main/java/freemarker/ext/beans/UnsafeMethods.java +++ b/src/main/java/freemarker/ext/beans/UnsafeMethods.java @@ -21,7 +21,6 @@ package freemarker.ext.beans; import java.io.InputStream; import java.lang.reflect.Method; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -34,6 +33,7 @@ import freemarker.template.utility.ClassUtil; class UnsafeMethods { + private static final String UNSAFE_METHODS_PROPERTIES = "unsafeMethods.properties"; private static final Set UNSAFE_METHODS = createUnsafeMethodsSet(); private UnsafeMethods() { } @@ -45,36 +45,37 @@ class UnsafeMethods { private static final Set createUnsafeMethodsSet() { Properties props = new Properties(); InputStream in = BeansWrapper.class.getResourceAsStream("unsafeMethods.properties"); - if (in != null) { - String methodSpec = null; + if (in == null) { + throw new IllegalStateException("Class loader resource not found: " + + BeansWrapper.class.getPackage().getName() + UNSAFE_METHODS_PROPERTIES); + } + String methodSpec = null; + try { try { + props.load(in); + } finally { + in.close(); + } + Set set = new HashSet(props.size() * 4 / 3, 1f); + Map primClasses = createPrimitiveClassesMap(); + for (Iterator iterator = props.keySet().iterator(); iterator.hasNext(); ) { + methodSpec = (String) iterator.next(); try { - props.load(in); - } finally { - in.close(); - } - Set set = new HashSet(props.size() * 4 / 3, 1f); - Map primClasses = createPrimitiveClassesMap(); - for (Iterator iterator = props.keySet().iterator(); iterator.hasNext(); ) { - methodSpec = (String) iterator.next(); - try { - set.add(parseMethodSpec(methodSpec, primClasses)); - } catch (ClassNotFoundException e) { - if (ClassIntrospector.DEVELOPMENT_MODE) { - throw e; - } - } catch (NoSuchMethodException e) { - if (ClassIntrospector.DEVELOPMENT_MODE) { - throw e; - } + set.add(parseMethodSpec(methodSpec, primClasses)); + } catch (ClassNotFoundException e) { + if (ClassIntrospector.DEVELOPMENT_MODE) { + throw e; + } + } catch (NoSuchMethodException e) { + if (ClassIntrospector.DEVELOPMENT_MODE) { + throw e; } } - return set; - } catch (Exception e) { - throw new RuntimeException("Could not load unsafe method " + methodSpec + " " + e.getClass().getName() + " " + e.getMessage()); } + return set; + } catch (Exception e) { + throw new RuntimeException("Could not load unsafe method " + methodSpec + " " + e.getClass().getName() + " " + e.getMessage()); } - return Collections.EMPTY_SET; } private static Method parseMethodSpec(String methodSpec, Map primClasses)