Fixing build failure

This commit is contained in:
Nick Goupinets 2021-03-09 09:54:57 -05:00
parent ab4f02b2bd
commit ed511565ae
1 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.interceptor; package ca.uhn.fhir.rest.server.interceptor;
import ca.uhn.fhir.util.ClasspathUtil;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -16,15 +17,21 @@ import java.util.Properties;
public class ConfigLoader { public class ConfigLoader {
private static final Logger ourLog = LoggerFactory.getLogger(ConfigLoader.class); private static final Logger ourLog = LoggerFactory.getLogger(ConfigLoader.class);
public static final String CLASSPATH_PREFIX = "classpath:";
public static String loadResourceContent(String theResourcePath) { public static String loadResourceContent(String theResourcePath) {
try { if(theResourcePath.startsWith(CLASSPATH_PREFIX)) {
URL url = ResourceUtils.getURL(theResourcePath); theResourcePath = theResourcePath.substring(CLASSPATH_PREFIX.length());
File file = ResourceUtils.getFile(url);
return IOUtils.toString(new FileReader(file));
} catch (Exception e) {
throw new RuntimeException(String.format("Unable to load resource %s", theResourcePath), e);
} }
return ClasspathUtil.loadResource(theResourcePath);
// FIXME the code below seems to be failing in the build server...
// try {
// URL url = ResourceUtils.getURL(theResourcePath);
// File file = ResourceUtils.getFile(url);
// return IOUtils.toString(new FileReader(file));
// } catch (Exception e) {
// throw new RuntimeException(String.format("Unable to load resource %s", theResourcePath), e);
// }
} }
public static Properties loadProperties(String theResourcePath) { public static Properties loadProperties(String theResourcePath) {