mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 19:00:38 +00:00
#1604 - Open URL resources without caching
This commit is contained in:
@@ -4,6 +4,7 @@ import io.ebean.ScriptRunner;
|
||||
import io.ebean.migration.ddl.DdlRunner;
|
||||
import io.ebean.migration.runner.ScriptTransform;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.util.UrlHelper;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.IOException;
|
||||
@@ -63,7 +64,7 @@ class DScriptRunner implements ScriptRunner {
|
||||
throw new IllegalArgumentException("resource is null?");
|
||||
}
|
||||
|
||||
try (InputStream inputStream = resource.openStream()) {
|
||||
try (InputStream inputStream = UrlHelper.openNoCache(resource)) {
|
||||
return readContent(new InputStreamReader(inputStream));
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.server.core.bootup;
|
||||
|
||||
import io.ebean.util.StringHelper;
|
||||
import io.ebeaninternal.util.UrlHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -59,7 +60,7 @@ class ManifestReader {
|
||||
try {
|
||||
Enumeration<URL> resources = classLoader.getResources(resourcePath);
|
||||
while (resources.hasMoreElements()) {
|
||||
try (InputStream is = resources.nextElement().openStream()) {
|
||||
try (InputStream is = UrlHelper.openNoCache(resources.nextElement())) {
|
||||
read(new Manifest(is));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.ebeaninternal.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* Helper to open URL content without file descriptor caching (by underlying JDK JarURLConnection).
|
||||
*/
|
||||
public class UrlHelper {
|
||||
|
||||
/**
|
||||
* Open the URL content without using caching returning the resulting InputStream.
|
||||
*/
|
||||
public static InputStream openNoCache(URL url) throws IOException {
|
||||
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
urlConnection.setUseCaches(false);
|
||||
return urlConnection.getInputStream();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.xmlmapping;
|
||||
|
||||
import io.ebeaninternal.util.UrlHelper;
|
||||
import io.ebeaninternal.xmlmapping.model.XmEbean;
|
||||
import org.avaje.classpath.scanner.Resource;
|
||||
|
||||
@@ -41,7 +42,7 @@ public class XmlMappingReader {
|
||||
List<XmEbean> mappings = new ArrayList<>();
|
||||
while (resources.hasMoreElements()) {
|
||||
URL url = resources.nextElement();
|
||||
try (InputStream is = url.openStream()) {
|
||||
try (InputStream is = UrlHelper.openNoCache(url)) {
|
||||
mappings.add(XmlMappingReader.read(is));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user