Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for classpath resource concurrent access issue #37

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/java/freemarker/ext/beans/UnsafeMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand All @@ -44,13 +45,15 @@ static boolean isUnsafeMethod(Method method) {

private static final Set createUnsafeMethodsSet() {
Properties props = new Properties();
InputStream in = BeansWrapper.class.getResourceAsStream("unsafeMethods.properties");
if (in == null) {

URL unsafeMethodsResource = BeansWrapper.class.getResource("unsafeMethods.properties");
if (unsafeMethodsResource == null) {
throw new IllegalStateException("Class loader resource not found: "
+ BeansWrapper.class.getPackage().getName() + UNSAFE_METHODS_PROPERTIES);
}
String methodSpec = null;
try {
InputStream in = unsafeMethodsResource.openStream();
try {
props.load(in);
} finally {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/freemarker/template/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.InputStream;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -436,11 +437,12 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
static {
try {
Properties vp = new Properties();
InputStream ins = Configuration.class.getClassLoader()
.getResourceAsStream(VERSION_PROPERTIES_PATH);
if (ins == null) {
URL versionPropertiesResource = Configuration.class.getClassLoader()
.getResource(VERSION_PROPERTIES_PATH);
if (versionPropertiesResource == null) {
throw new RuntimeException("Version file is missing.");
} else {
InputStream ins = versionPropertiesResource.openStream();
try {
vp.load(ins);
} finally {
Expand Down