提交 387864d5 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove leftover support of File.deleteOnExit()

上级 dbc36dc0
...@@ -63,8 +63,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -63,8 +63,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>PostgreSQL catalog: use BEFORE SELECT triggers instead of views over metadata tables. </li><li>PostgreSQL catalog: use BEFORE SELECT triggers instead of views over metadata tables.
</li><li>Test very large databases and LOBs (up to 256 GB). </li><li>Test very large databases and LOBs (up to 256 GB).
</li><li>Store all temp files in the temp directory. </li><li>Store all temp files in the temp directory.
</li><li>Don't use temp files, specially not deleteOnExit (bug 4513817: File.deleteOnExit consumes memory).
Also to allow opening client / server (remote) connections when using LOBs.
</li><li>Make DDL (Data Definition) operations transactional. </li><li>Make DDL (Data Definition) operations transactional.
</li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED). </li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED).
</li><li>Groovy Stored Procedures: http://groovy.codehaus.org/GSQL </li><li>Groovy Stored Procedures: http://groovy.codehaus.org/GSQL
......
...@@ -1956,7 +1956,7 @@ public class Database implements DataHandler { ...@@ -1956,7 +1956,7 @@ public class Database implements DataHandler {
if (!persistent) { if (!persistent) {
name = "memFS:" + name; name = "memFS:" + name;
} }
return FileUtils.createTempFile(name, Constants.SUFFIX_TEMP_FILE, false, inTempDir); return FileUtils.createTempFile(name, Constants.SUFFIX_TEMP_FILE, inTempDir);
} catch (IOException e) { } catch (IOException e) {
throw DbException.convertIOException(e, databaseName); throw DbException.convertIOException(e, databaseName);
} }
......
...@@ -376,7 +376,7 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -376,7 +376,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
traceSystem.setLevelFile(level); traceSystem.setLevelFile(level);
if (level > 0 && level < 4) { if (level > 0 && level < 4) {
String file = FileUtils.createTempFile(prefix, String file = FileUtils.createTempFile(prefix,
Constants.SUFFIX_TRACE_FILE, false, false); Constants.SUFFIX_TRACE_FILE, false);
traceSystem.setFileName(file); traceSystem.setFileName(file);
} }
} catch (IOException e) { } catch (IOException e) {
......
...@@ -159,7 +159,7 @@ public abstract class MVTempResult implements ResultExternal { ...@@ -159,7 +159,7 @@ public abstract class MVTempResult implements ResultExternal {
*/ */
MVTempResult(Database database, int columnCount, int visibleColumnCount) { MVTempResult(Database database, int columnCount, int visibleColumnCount) {
try { try {
String fileName = FileUtils.createTempFile("h2tmp", Constants.SUFFIX_TEMP_FILE, false, true); String fileName = FileUtils.createTempFile("h2tmp", Constants.SUFFIX_TEMP_FILE, true);
Builder builder = new MVStore.Builder().fileName(fileName).cacheSize(0).autoCommitDisabled(); Builder builder = new MVStore.Builder().fileName(fileName).cacheSize(0).autoCommitDisabled();
byte[] key = database.getFileEncryptionKey(); byte[] key = database.getFileEncryptionKey();
if (key != null) { if (key != null) {
......
...@@ -250,14 +250,11 @@ public abstract class FilePath { ...@@ -250,14 +250,11 @@ public abstract class FilePath {
* Create a new temporary file. * Create a new temporary file.
* *
* @param suffix the suffix * @param suffix the suffix
* @param deleteOnExit if the file should be deleted when the virtual
* machine exists
* @param inTempDir if the file should be stored in the temporary directory * @param inTempDir if the file should be stored in the temporary directory
* @return the name of the created file * @return the name of the created file
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException {
while (true) { while (true) {
FilePath p = getPath(name + getNextTempFileNamePart(false) + suffix); FilePath p = getPath(name + getNextTempFileNamePart(false) + suffix);
if (p.exists() || !p.createFile()) { if (p.exists() || !p.createFile()) {
......
...@@ -381,8 +381,7 @@ public class FilePathDisk extends FilePath { ...@@ -381,8 +381,7 @@ public class FilePathDisk extends FilePath {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException {
String fileName = name + "."; String fileName = name + ".";
String prefix = new File(fileName).getName(); String prefix = new File(fileName).getName();
File dir; File dir;
...@@ -399,15 +398,6 @@ public class FilePathDisk extends FilePath { ...@@ -399,15 +398,6 @@ public class FilePathDisk extends FilePath {
getNextTempFileNamePart(true); getNextTempFileNamePart(true);
continue; continue;
} }
if (deleteOnExit) {
try {
f.deleteOnExit();
} catch (Throwable e) {
// sometimes this throws a NullPointerException
// at java.io.DeleteOnExitHook.add(DeleteOnExitHook.java:33)
// we can ignore it
}
}
return get(f.getCanonicalPath()); return get(f.getCanonicalPath());
} }
} }
......
...@@ -46,11 +46,9 @@ public class FilePathRec extends FilePathWrapper { ...@@ -46,11 +46,9 @@ public class FilePathRec extends FilePathWrapper {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException { log(Recorder.CREATE_TEMP_FILE, unwrap(name) + ":" + suffix + ":" + inTempDir);
log(Recorder.CREATE_TEMP_FILE, unwrap(name) + ":" + suffix + ":" + return super.createTempFile(suffix, inTempDir);
deleteOnExit + ":" + inTempDir);
return super.createTempFile(suffix, deleteOnExit, inTempDir);
} }
@Override @Override
......
...@@ -158,9 +158,8 @@ public abstract class FilePathWrapper extends FilePath { ...@@ -158,9 +158,8 @@ public abstract class FilePathWrapper extends FilePath {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException { return wrap(base.createTempFile(suffix, inTempDir));
return wrap(base.createTempFile(suffix, deleteOnExit, inTempDir));
} }
} }
...@@ -234,13 +234,11 @@ public class FilePathZip extends FilePath { ...@@ -234,13 +234,11 @@ public class FilePathZip extends FilePath {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException {
if (!inTempDir) { if (!inTempDir) {
throw new IOException("File system is read-only"); throw new IOException("File system is read-only");
} }
return new FilePathDisk().getPath(name).createTempFile(suffix, return new FilePathDisk().getPath(name).createTempFile(suffix, true);
deleteOnExit, true);
} }
@Override @Override
......
...@@ -335,15 +335,12 @@ public class FileUtils { ...@@ -335,15 +335,12 @@ public class FileUtils {
* @param prefix the prefix of the file name (including directory name if * @param prefix the prefix of the file name (including directory name if
* required) * required)
* @param suffix the suffix * @param suffix the suffix
* @param deleteOnExit if the file should be deleted when the virtual
* machine exists
* @param inTempDir if the file should be stored in the temporary directory * @param inTempDir if the file should be stored in the temporary directory
* @return the name of the created file * @return the name of the created file
*/ */
public static String createTempFile(String prefix, String suffix, public static String createTempFile(String prefix, String suffix,
boolean deleteOnExit, boolean inTempDir) throws IOException { boolean inTempDir) throws IOException {
return FilePath.get(prefix).createTempFile( return FilePath.get(prefix).createTempFile(suffix, inTempDir).toString();
suffix, deleteOnExit, inTempDir).toString();
} }
/** /**
......
...@@ -179,7 +179,7 @@ public class ValueLobDb extends Value { ...@@ -179,7 +179,7 @@ public class ValueLobDb extends Value {
if (path.isEmpty()) { if (path.isEmpty()) {
path = SysProperties.PREFIX_TEMP_FILE; path = SysProperties.PREFIX_TEMP_FILE;
} }
return FileUtils.createTempFile(path, Constants.SUFFIX_TEMP_FILE, false, true); return FileUtils.createTempFile(path, Constants.SUFFIX_TEMP_FILE, true);
} }
/** /**
......
...@@ -370,7 +370,7 @@ public class TestFileSystem extends TestDb { ...@@ -370,7 +370,7 @@ public class TestFileSystem extends TestDb {
new AssertThrows(IOException.class) { new AssertThrows(IOException.class) {
@Override @Override
public void test() throws IOException { public void test() throws IOException {
FileUtils.createTempFile(f, ".tmp", false, false); FileUtils.createTempFile(f, ".tmp", false);
}}; }};
final FileChannel channel = FileUtils.open(f, "r"); final FileChannel channel = FileUtils.open(f, "r");
new AssertThrows(IOException.class) { new AssertThrows(IOException.class) {
...@@ -670,7 +670,7 @@ public class TestFileSystem extends TestDb { ...@@ -670,7 +670,7 @@ public class TestFileSystem extends TestDb {
private void testRandomAccess(String fsBase, int seed) throws Exception { private void testRandomAccess(String fsBase, int seed) throws Exception {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
String s = FileUtils.createTempFile(fsBase + "/tmp", ".tmp", false, false); String s = FileUtils.createTempFile(fsBase + "/tmp", ".tmp", false);
File file = new File(TestBase.BASE_TEST_DIR + "/tmp"); File file = new File(TestBase.BASE_TEST_DIR + "/tmp");
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
file.delete(); file.delete();
...@@ -784,7 +784,7 @@ public class TestFileSystem extends TestDb { ...@@ -784,7 +784,7 @@ public class TestFileSystem extends TestDb {
private void testTempFile(String fsBase) throws Exception { private void testTempFile(String fsBase) throws Exception {
int len = 10000; int len = 10000;
String s = FileUtils.createTempFile(fsBase + "/tmp", ".tmp", false, false); String s = FileUtils.createTempFile(fsBase + "/tmp", ".tmp", false);
OutputStream out = FileUtils.newOutputStream(s, false); OutputStream out = FileUtils.newOutputStream(s, false);
byte[] buffer = new byte[len]; byte[] buffer = new byte[len];
out.write(buffer); out.write(buffer);
...@@ -804,7 +804,7 @@ public class TestFileSystem extends TestDb { ...@@ -804,7 +804,7 @@ public class TestFileSystem extends TestDb {
} }
private void testConcurrent(String fsBase) throws Exception { private void testConcurrent(String fsBase) throws Exception {
String s = FileUtils.createTempFile(fsBase + "/tmp", ".tmp", false, false); String s = FileUtils.createTempFile(fsBase + "/tmp", ".tmp", false);
File file = new File(TestBase.BASE_TEST_DIR + "/tmp"); File file = new File(TestBase.BASE_TEST_DIR + "/tmp");
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
file.delete(); file.delete();
......
...@@ -191,10 +191,9 @@ public class FilePathDebug extends FilePathWrapper { ...@@ -191,10 +191,9 @@ public class FilePathDebug extends FilePathWrapper {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException { trace(name, "createTempFile", suffix, inTempDir);
trace(name, "createTempFile", suffix, deleteOnExit, inTempDir); return super.createTempFile(suffix, inTempDir);
return super.createTempFile(suffix, deleteOnExit, inTempDir);
} }
/** /**
......
...@@ -198,9 +198,8 @@ public class FilePathUnstable extends FilePathWrapper { ...@@ -198,9 +198,8 @@ public class FilePathUnstable extends FilePathWrapper {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException { return super.createTempFile(suffix, inTempDir);
return super.createTempFile(suffix, deleteOnExit, inTempDir);
} }
@Override @Override
......
...@@ -61,13 +61,11 @@ public class FilePathZip2 extends FilePath { ...@@ -61,13 +61,11 @@ public class FilePathZip2 extends FilePath {
} }
@Override @Override
public FilePath createTempFile(String suffix, boolean deleteOnExit, public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException {
boolean inTempDir) throws IOException {
if (!inTempDir) { if (!inTempDir) {
throw new IOException("File system is read-only"); throw new IOException("File system is read-only");
} }
return new FilePathDisk().getPath(name).createTempFile(suffix, return new FilePathDisk().getPath(name).createTempFile(suffix, true);
deleteOnExit, true);
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论