[1/3] incubator-freemarker git commit: (Some code cleanup)
Repository: incubator-freemarker Updated Branches: refs/heads/2.3 e5db86b36 -> 22b70e941 (Some code cleanup) Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/031762b0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/031762b0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/031762b0 Branch: refs/heads/2.3 Commit: 031762b0e272851f048d63b5fccf2a1bef73d0bd Parents: 15b97af Author: ddekanyAuthored: Sun Oct 8 23:56:34 2017 +0200 Committer: ddekany Committed: Sun Oct 8 23:56:46 2017 +0200 -- src/main/java/freemarker/ext/beans/UnsafeMethods.java | 5 ++--- src/main/java/freemarker/ext/jsp/TaglibFactory.java | 6 +++--- src/main/java/freemarker/template/Configuration.java | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/031762b0/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 c7b5f46..249a6c1 100644 --- a/src/main/java/freemarker/ext/beans/UnsafeMethods.java +++ b/src/main/java/freemarker/ext/beans/UnsafeMethods.java @@ -22,7 +22,6 @@ package freemarker.ext.beans; import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -46,9 +45,9 @@ class UnsafeMethods { Properties props = ClassUtil.loadProperties(BeansWrapper.class, UNSAFE_METHODS_PROPERTIES); Set set = new HashSet(props.size() * 4 / 3, 1f); Map primClasses = createPrimitiveClassesMap(); -for (Iterator iterator = props.keySet().iterator(); iterator.hasNext(); ) { +for (Object key : props.keySet()) { try { -set.add(parseMethodSpec((String) iterator.next(), primClasses)); +set.add(parseMethodSpec((String) key, primClasses)); } catch (ClassNotFoundException e) { if (ClassIntrospector.DEVELOPMENT_MODE) { throw e; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/031762b0/src/main/java/freemarker/ext/jsp/TaglibFactory.java -- diff --git a/src/main/java/freemarker/ext/jsp/TaglibFactory.java b/src/main/java/freemarker/ext/jsp/TaglibFactory.java index de4bcf3..909a372 100644 --- a/src/main/java/freemarker/ext/jsp/TaglibFactory.java +++ b/src/main/java/freemarker/ext/jsp/TaglibFactory.java @@ -1257,9 +1257,9 @@ public class TaglibFactory implements TemplateHashModel { public InputStream getInputStream() throws IOException { ClassLoader tccl = tryGetThreadContextClassLoader(); if (tccl != null) { -InputStream r = ClassUtil.getReasourceAsStream(tccl, resourcePath, true); -if (r != null) { -return r; +InputStream ins = ClassUtil.getReasourceAsStream(tccl, resourcePath, true); +if (ins != null) { +return ins; } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/031762b0/src/main/java/freemarker/template/Configuration.java -- diff --git a/src/main/java/freemarker/template/Configuration.java b/src/main/java/freemarker/template/Configuration.java index d4d6863..8dc77a2 100644 --- a/src/main/java/freemarker/template/Configuration.java +++ b/src/main/java/freemarker/template/Configuration.java @@ -435,6 +435,7 @@ public class Configuration extends Configurable implements Cloneable, ParserConf static { try { Properties props = ClassUtil.loadProperties(Configuration.class, VERSION_PROPERTIES_PATH); + String versionString = getRequiredVersionProperty(props, "version"); Date buildDate;
[1/2] incubator-freemarker git commit: (Some code cleanup)
Repository: incubator-freemarker Updated Branches: refs/heads/2.3-gae 15b97afa5 -> d2a26061e (Some code cleanup) Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/031762b0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/031762b0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/031762b0 Branch: refs/heads/2.3-gae Commit: 031762b0e272851f048d63b5fccf2a1bef73d0bd Parents: 15b97af Author: ddekanyAuthored: Sun Oct 8 23:56:34 2017 +0200 Committer: ddekany Committed: Sun Oct 8 23:56:46 2017 +0200 -- src/main/java/freemarker/ext/beans/UnsafeMethods.java | 5 ++--- src/main/java/freemarker/ext/jsp/TaglibFactory.java | 6 +++--- src/main/java/freemarker/template/Configuration.java | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/031762b0/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 c7b5f46..249a6c1 100644 --- a/src/main/java/freemarker/ext/beans/UnsafeMethods.java +++ b/src/main/java/freemarker/ext/beans/UnsafeMethods.java @@ -22,7 +22,6 @@ package freemarker.ext.beans; import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -46,9 +45,9 @@ class UnsafeMethods { Properties props = ClassUtil.loadProperties(BeansWrapper.class, UNSAFE_METHODS_PROPERTIES); Set set = new HashSet(props.size() * 4 / 3, 1f); Map primClasses = createPrimitiveClassesMap(); -for (Iterator iterator = props.keySet().iterator(); iterator.hasNext(); ) { +for (Object key : props.keySet()) { try { -set.add(parseMethodSpec((String) iterator.next(), primClasses)); +set.add(parseMethodSpec((String) key, primClasses)); } catch (ClassNotFoundException e) { if (ClassIntrospector.DEVELOPMENT_MODE) { throw e; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/031762b0/src/main/java/freemarker/ext/jsp/TaglibFactory.java -- diff --git a/src/main/java/freemarker/ext/jsp/TaglibFactory.java b/src/main/java/freemarker/ext/jsp/TaglibFactory.java index de4bcf3..909a372 100644 --- a/src/main/java/freemarker/ext/jsp/TaglibFactory.java +++ b/src/main/java/freemarker/ext/jsp/TaglibFactory.java @@ -1257,9 +1257,9 @@ public class TaglibFactory implements TemplateHashModel { public InputStream getInputStream() throws IOException { ClassLoader tccl = tryGetThreadContextClassLoader(); if (tccl != null) { -InputStream r = ClassUtil.getReasourceAsStream(tccl, resourcePath, true); -if (r != null) { -return r; +InputStream ins = ClassUtil.getReasourceAsStream(tccl, resourcePath, true); +if (ins != null) { +return ins; } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/031762b0/src/main/java/freemarker/template/Configuration.java -- diff --git a/src/main/java/freemarker/template/Configuration.java b/src/main/java/freemarker/template/Configuration.java index d4d6863..8dc77a2 100644 --- a/src/main/java/freemarker/template/Configuration.java +++ b/src/main/java/freemarker/template/Configuration.java @@ -435,6 +435,7 @@ public class Configuration extends Configurable implements Cloneable, ParserConf static { try { Properties props = ClassUtil.loadProperties(Configuration.class, VERSION_PROPERTIES_PATH); + String versionString = getRequiredVersionProperty(props, "version"); Date buildDate;
[3/3] incubator-freemarker git commit: Merge remote-tracking branch 'origin/2.3-gae' into 2.3
Merge remote-tracking branch 'origin/2.3-gae' into 2.3 Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/22b70e94 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/22b70e94 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/22b70e94 Branch: refs/heads/2.3 Commit: 22b70e9410015108b3056364e0f866bfd9b0244c Parents: e5db86b d2a2606 Author: ddekanyAuthored: Sun Oct 8 23:58:07 2017 +0200 Committer: ddekany Committed: Sun Oct 8 23:58:07 2017 +0200 -- .../freemarker/ext/beans/UnsafeMethods.java | 5 ++--- .../java/freemarker/ext/jsp/TaglibFactory.java | 6 +++--- .../java/freemarker/template/Configuration.java | 1 + .../freemarker/template/utility/ClassUtil.java | 21 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) --
[2/3] incubator-freemarker git commit: Added workaround against any kind of exception related to https://github.com/apache/incubator-freemarker/pull/37...
Added workaround against any kind of exception related to https://github.com/apache/incubator-freemarker/pull/37... Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/d2a26061 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/d2a26061 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/d2a26061 Branch: refs/heads/2.3 Commit: d2a26061efc0585809766c3d5d5eb74e6af20e48 Parents: 031762b Author: ddekanyAuthored: Sun Oct 8 23:57:27 2017 +0200 Committer: ddekany Committed: Sun Oct 8 23:57:27 2017 +0200 -- .../freemarker/template/utility/ClassUtil.java | 21 ++-- 1 file changed, 11 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d2a26061/src/main/java/freemarker/template/utility/ClassUtil.java -- diff --git a/src/main/java/freemarker/template/utility/ClassUtil.java b/src/main/java/freemarker/template/utility/ClassUtil.java index d5601f2..6b262f5 100644 --- a/src/main/java/freemarker/template/utility/ClassUtil.java +++ b/src/main/java/freemarker/template/utility/ClassUtil.java @@ -387,7 +387,7 @@ public class ClassUtil { /** * Very similar to {@link Class#getResourceAsStream(String)}, but throws {@link IOException} instead of returning * {@code null} if {@code optional} is {@code false}, and attempts to work around "IllegalStateException: zip file - * closed" issues (caused by bugs outside of FreeMarker). + * closed" and related issues (caused by bugs outside of FreeMarker). * * @return If {@code optional} is {@code false}, it's never {@code null}, otherwise {@code null} indicates that the * resource doesn't exist. @@ -401,9 +401,9 @@ public class ClassUtil { InputStream ins; try { ins = baseClass.getResourceAsStream(resource); -} catch (IllegalStateException e) { -// Workaround for "IllegalStateException: zip file closed". This happens due to bugs outside of FreeMarker, -// but we try to work it around anyway. +} catch (Exception e) { +// Workaround for "IllegalStateException: zip file closed", and other related exceptions. This happens due +// to bugs outside of FreeMarker, but we try to work it around anyway. URL url = baseClass.getResource(resource); ins = url != null ? url.openStream() : null; } @@ -424,7 +424,7 @@ public class ClassUtil { InputStream ins; try { ins = classLoader.getResourceAsStream(resource); -} catch (IllegalStateException e) { +} catch (Exception e) { URL url = classLoader.getResource(resource); ins = url != null ? url.openStream() : null; } @@ -436,7 +436,8 @@ public class ClassUtil { } /** - * Loads a class loader resource into a {@link Properties}; tries to work around "zip file closed" errors. + * Loads a class loader resource into a {@link Properties}; tries to work around "zip file closed" and related + * errors. * * @since 2.3.27 */ @@ -447,18 +448,18 @@ public class ClassUtil { try { try { ins = baseClass.getResourceAsStream(resource); -} catch (IllegalStateException e) { +} catch (Exception e) { throw new MaybeZipFileClosedException(); } checkInputStreamNotNull(ins, baseClass, resource); try { props.load(ins); -} catch (ZipException e) { +} catch (Exception e) { throw new MaybeZipFileClosedException(); } } catch (MaybeZipFileClosedException e) { -// Workaround for "zip file closed" exception. This happens due to bugs outside of FreeMarker, but we try -// to work it around anyway. +// Workaround for "zip file closed" exception, and other related exceptions. This happens due to bugs +// outside of FreeMarker, but we try to work it around anyway. URL url = baseClass.getResource(resource); ins = url != null ? url.openStream() : null; checkInputStreamNotNull(ins, baseClass, resource);
[4/5] incubator-freemarker git commit: Added workaround against "ZipException: ZipFile closed" when loading properties. Related to https://github.com/apache/incubator-freemarker/pull/37.
Added workaround against "ZipException: ZipFile closed" when loading properties. Related to https://github.com/apache/incubator-freemarker/pull/37. Also, fixed bug where we didn't try to find TLD resources with the thread context class loader. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/15b97afa Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/15b97afa Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/15b97afa Branch: refs/heads/2.3 Commit: 15b97afa5026f6a53101f582840c11cc4d07e365 Parents: bd7498e Author: ddekanyAuthored: Sun Oct 8 13:52:12 2017 +0200 Committer: ddekany Committed: Sun Oct 8 13:52:12 2017 +0200 -- .../freemarker/ext/beans/UnsafeMethods.java | 15 +--- .../java/freemarker/ext/jsp/TaglibFactory.java | 9 +- .../java/freemarker/template/Configuration.java | 16 +--- .../freemarker/template/utility/ClassUtil.java | 94 src/manual/en_US/book.xml | 18 +++- 5 files changed, 104 insertions(+), 48 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15b97afa/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 f590085..c7b5f46 100644 --- a/src/main/java/freemarker/ext/beans/UnsafeMethods.java +++ b/src/main/java/freemarker/ext/beans/UnsafeMethods.java @@ -19,7 +19,6 @@ package freemarker.ext.beans; -import java.io.InputStream; import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; @@ -43,21 +42,13 @@ class UnsafeMethods { } private static final Set createUnsafeMethodsSet() { -Properties props = new Properties(); -String methodSpec = null; try { -InputStream in = ClassUtil.getReasourceAsStream(BeansWrapper.class, UNSAFE_METHODS_PROPERTIES); -try { -props.load(in); -} finally { -in.close(); -} +Properties props = ClassUtil.loadProperties(BeansWrapper.class, UNSAFE_METHODS_PROPERTIES); 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)); +set.add(parseMethodSpec((String) iterator.next(), primClasses)); } catch (ClassNotFoundException e) { if (ClassIntrospector.DEVELOPMENT_MODE) { throw e; @@ -70,7 +61,7 @@ class UnsafeMethods { } return set; } catch (Exception e) { -throw new RuntimeException("Could not load unsafe method " + methodSpec + " " + e.getClass().getName() + " " + e.getMessage()); +throw new RuntimeException("Could not load unsafe method set", e); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15b97afa/src/main/java/freemarker/ext/jsp/TaglibFactory.java -- diff --git a/src/main/java/freemarker/ext/jsp/TaglibFactory.java b/src/main/java/freemarker/ext/jsp/TaglibFactory.java index 0dc07b1..de4bcf3 100644 --- a/src/main/java/freemarker/ext/jsp/TaglibFactory.java +++ b/src/main/java/freemarker/ext/jsp/TaglibFactory.java @@ -1257,16 +1257,19 @@ public class TaglibFactory implements TemplateHashModel { public InputStream getInputStream() throws IOException { ClassLoader tccl = tryGetThreadContextClassLoader(); if (tccl != null) { -return ClassUtil.getReasourceAsStream(getClass(), resourcePath); +InputStream r = ClassUtil.getReasourceAsStream(tccl, resourcePath, true); +if (r != null) { +return r; +} } -return ClassUtil.getReasourceAsStream(getClass(), resourcePath); +return ClassUtil.getReasourceAsStream(getClass(), resourcePath, false); } public String getXmlSystemId() throws IOException { ClassLoader tccl = tryGetThreadContextClassLoader(); if (tccl != null) { -final URL url = getClass().getResource(resourcePath); +final URL url = tccl.getResource(resourcePath); if (url != null) {
[5/5] incubator-freemarker git commit: Merge remote-tracking branch 'origin/2.3-gae' into 2.3
Merge remote-tracking branch 'origin/2.3-gae' into 2.3 Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/e5db86b3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/e5db86b3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/e5db86b3 Branch: refs/heads/2.3 Commit: e5db86b36cd2e67d100eaa9e29e92d7b675cdf82 Parents: e719094 15b97af Author: ddekanyAuthored: Sun Oct 8 20:42:46 2017 +0200 Committer: ddekany Committed: Sun Oct 8 20:42:46 2017 +0200 -- .../freemarker/ext/beans/UnsafeMethods.java | 15 +--- .../java/freemarker/ext/jsp/TaglibFactory.java | 9 +- .../java/freemarker/template/Configuration.java | 16 +--- .../freemarker/template/utility/ClassUtil.java | 94 src/manual/en_US/book.xml | 18 +++- 5 files changed, 104 insertions(+), 48 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e5db86b3/src/manual/en_US/book.xml --
incubator-freemarker git commit: Added workaround against "ZipException: ZipFile closed" when loading properties. Related to https://github.com/apache/incubator-freemarker/pull/37.
Repository: incubator-freemarker Updated Branches: refs/heads/2.3-gae bd7498e8d -> 15b97afa5 Added workaround against "ZipException: ZipFile closed" when loading properties. Related to https://github.com/apache/incubator-freemarker/pull/37. Also, fixed bug where we didn't try to find TLD resources with the thread context class loader. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/15b97afa Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/15b97afa Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/15b97afa Branch: refs/heads/2.3-gae Commit: 15b97afa5026f6a53101f582840c11cc4d07e365 Parents: bd7498e Author: ddekanyAuthored: Sun Oct 8 13:52:12 2017 +0200 Committer: ddekany Committed: Sun Oct 8 13:52:12 2017 +0200 -- .../freemarker/ext/beans/UnsafeMethods.java | 15 +--- .../java/freemarker/ext/jsp/TaglibFactory.java | 9 +- .../java/freemarker/template/Configuration.java | 16 +--- .../freemarker/template/utility/ClassUtil.java | 94 src/manual/en_US/book.xml | 18 +++- 5 files changed, 104 insertions(+), 48 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15b97afa/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 f590085..c7b5f46 100644 --- a/src/main/java/freemarker/ext/beans/UnsafeMethods.java +++ b/src/main/java/freemarker/ext/beans/UnsafeMethods.java @@ -19,7 +19,6 @@ package freemarker.ext.beans; -import java.io.InputStream; import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; @@ -43,21 +42,13 @@ class UnsafeMethods { } private static final Set createUnsafeMethodsSet() { -Properties props = new Properties(); -String methodSpec = null; try { -InputStream in = ClassUtil.getReasourceAsStream(BeansWrapper.class, UNSAFE_METHODS_PROPERTIES); -try { -props.load(in); -} finally { -in.close(); -} +Properties props = ClassUtil.loadProperties(BeansWrapper.class, UNSAFE_METHODS_PROPERTIES); 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)); +set.add(parseMethodSpec((String) iterator.next(), primClasses)); } catch (ClassNotFoundException e) { if (ClassIntrospector.DEVELOPMENT_MODE) { throw e; @@ -70,7 +61,7 @@ class UnsafeMethods { } return set; } catch (Exception e) { -throw new RuntimeException("Could not load unsafe method " + methodSpec + " " + e.getClass().getName() + " " + e.getMessage()); +throw new RuntimeException("Could not load unsafe method set", e); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15b97afa/src/main/java/freemarker/ext/jsp/TaglibFactory.java -- diff --git a/src/main/java/freemarker/ext/jsp/TaglibFactory.java b/src/main/java/freemarker/ext/jsp/TaglibFactory.java index 0dc07b1..de4bcf3 100644 --- a/src/main/java/freemarker/ext/jsp/TaglibFactory.java +++ b/src/main/java/freemarker/ext/jsp/TaglibFactory.java @@ -1257,16 +1257,19 @@ public class TaglibFactory implements TemplateHashModel { public InputStream getInputStream() throws IOException { ClassLoader tccl = tryGetThreadContextClassLoader(); if (tccl != null) { -return ClassUtil.getReasourceAsStream(getClass(), resourcePath); +InputStream r = ClassUtil.getReasourceAsStream(tccl, resourcePath, true); +if (r != null) { +return r; +} } -return ClassUtil.getReasourceAsStream(getClass(), resourcePath); +return ClassUtil.getReasourceAsStream(getClass(), resourcePath, false); } public String getXmlSystemId() throws IOException { ClassLoader tccl = tryGetThreadContextClassLoader(); if (tccl != null) { -final URL url = getClass().getResource(resourcePath); +final