aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoredler-san <19165931+edler-san@users.noreply.github.com>2025-07-01 11:38:38 +0200
committeredler-san <19165931+edler-san@users.noreply.github.com>2025-07-01 11:38:38 +0200
commit71d7d825c37ce40ed04bfbe74a91f85eb501c84d (patch)
tree0ed8f85d35f9b0829ab3291764f1ac40f34afc17
parente310099595309ce730336f940326d878a16731f4 (diff)
downloadvaadin-framework-fileToFilesReplacement.tar.gz
vaadin-framework-fileToFilesReplacement.zip
Switched from java.io to java.nio for safer temp file generationfileToFilesReplacement
-rw-r--r--client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java19
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForUpload.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/ui/MultiFileUploadTestTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/DisablingUploadTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/TestUploadMIMETypeTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetTest.java3
-rw-r--r--uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java3
14 files changed, 36 insertions, 22 deletions
diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java
index 1266a4d08e..f30a7e6324 100644
--- a/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java
+++ b/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java
@@ -25,6 +25,7 @@ import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.file.Files;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.prefs.Preferences;
@@ -288,7 +289,7 @@ public class CvalCheckerTest {
testManifest.getMainAttributes().putValue(VAADIN_ADDON_VERSION, "2");
// Create a temporary Jar
- File testJarFile = File.createTempFile("vaadin." + productName, ".jar");
+ File testJarFile = Files.createTempFile("vaadin." + productName, ".jar").toFile();
testJarFile.deleteOnExit();
JarOutputStream target = new JarOutputStream(
new FileOutputStream(testJarFile), testManifest);
@@ -357,7 +358,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_LicenseFileEmpty() throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
assertNull(licenseChecker
.readKeyFromFile(tmpLicenseFile.toURI().toURL(), 4));
@@ -368,7 +369,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_LicenseFileHasSingleUnidentifiedKey()
throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("this-is-a-license");
out.close();
@@ -382,7 +383,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_LicenseFileHasSingleIdentifiedKey()
throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("4=this-is-a-license");
out.close();
@@ -396,7 +397,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_LicenseFileHasMultipleKeys()
throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("4=this-is-a-license");
out.println("5=this-is-another-license");
@@ -413,7 +414,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_LicenseFileHasMultipleKeysWithWhitespace()
throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("4 = this-is-a-license");
out.println("5 = this-is-another-license");
@@ -429,7 +430,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_RequestedVersionMissing() throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("4 = this-is-a-license");
out.println("5 = this-is-another-license");
@@ -443,7 +444,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_FallbackToDefaultKey() throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("this-is-a-license");
out.println("5 = this-is-another-license");
@@ -462,7 +463,7 @@ public class CvalCheckerTest {
@Test
public void testReadKeyFromFile_FallbackToDefaultKeyReversed()
throws Exception {
- File tmpLicenseFile = File.createTempFile("license", "lic");
+ File tmpLicenseFile = Files.createTempFile("license", "lic").toFile();
PrintWriter out = new PrintWriter(tmpLicenseFile);
out.println("5 = this-is-another-license");
out.println("this-is-a-license");
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java b/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
index 0a8eb4bd27..eb2d7463cf 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
@@ -9,6 +9,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
+import java.nio.file.Files;
import com.vaadin.server.LegacyApplication;
import com.vaadin.server.StreamResource;
@@ -172,7 +173,7 @@ public class TestForStyledUpload extends LegacyApplication
final String tempFileName = "upload_tmpfile_"
+ System.currentTimeMillis();
try {
- file = File.createTempFile(tempFileName, null);
+ file = Files.createTempFile(tempFileName, null).toFile();
} catch (final IOException e) {
e.printStackTrace();
}
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForUpload.java b/uitest/src/main/java/com/vaadin/tests/TestForUpload.java
index f50f0ec332..6c1064d9c3 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForUpload.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForUpload.java
@@ -11,6 +11,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
+import java.nio.file.Files;
import com.vaadin.server.StreamResource;
import com.vaadin.shared.ui.ContentMode;
@@ -299,7 +300,7 @@ public class TestForUpload extends CustomComponent
final String tempFileName = "upload_tmpfile_"
+ System.currentTimeMillis();
try {
- file = File.createTempFile(tempFileName, null);
+ file = Files.createTempFile(tempFileName, null).toFile();
} catch (final IOException e) {
e.printStackTrace();
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java b/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java
index c6f9752a61..e98fea0569 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java
@@ -8,6 +8,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
@@ -62,7 +63,7 @@ public class FileDownloaderUI extends AbstractTestUIWithLog {
}, "demo.png");
addComponents("Dynamic image", resource, components);
try {
- File hugeFile = File.createTempFile("huge", ".txt");
+ File hugeFile = Files.createTempFile("huge", ".txt").toFile();
hugeFile.deleteOnExit();
BufferedOutputStream os = new BufferedOutputStream(
new FileOutputStream(hugeFile));
diff --git a/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java b/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java
index f7b4e647aa..08eb133076 100644
--- a/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java
+++ b/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java
@@ -2,6 +2,7 @@ package com.vaadin.tests.containers.filesystemcontainer;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
@@ -26,7 +27,7 @@ public class FileSystemContainerInTreeTable extends TestBase {
final File folder;
try {
- File tempFile = File.createTempFile("fsc-tt", "");
+ File tempFile = Files.createTempFile("fsc-tt", "").toFile();
tempFile.delete();
folder = new File(tempFile.getParent(), tempFile.getName());
folder.mkdir();
diff --git a/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java b/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java
index a41f13def5..6d96db917b 100644
--- a/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java
+++ b/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java
@@ -4,6 +4,7 @@ import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.Files;
import com.vaadin.server.FileResource;
import com.vaadin.tests.components.TestBase;
@@ -32,7 +33,7 @@ public class DownloadLargeFileResource extends TestBase {
private void createFile() {
try {
- File hugeFile = File.createTempFile("huge", ".txt");
+ File hugeFile = Files.createTempFile("huge", ".txt").toFile();
hugeFile.deleteOnExit();
BufferedOutputStream os = new BufferedOutputStream(
new FileOutputStream(hugeFile));
diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/MultiFileUploadTestTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/MultiFileUploadTestTest.java
index 422c7b4f89..111de1fef6 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/ui/MultiFileUploadTestTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/ui/MultiFileUploadTestTest.java
@@ -7,6 +7,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import org.junit.Test;
import org.openqa.selenium.By;
@@ -54,7 +55,7 @@ public class MultiFileUploadTestTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/DisablingUploadTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/DisablingUploadTest.java
index 3404641407..aa6d2007b0 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/DisablingUploadTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/DisablingUploadTest.java
@@ -4,6 +4,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import org.junit.Test;
import org.openqa.selenium.WebElement;
@@ -175,7 +176,7 @@ public class DisablingUploadTest extends SingleBrowserTest {
* @throws IOException
*/
private File createTempFile(boolean large) throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
if (large) {
writer.write(getLargeTempFileContents());
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java
index 3d791bd4b8..6e1262a07e 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java
@@ -4,6 +4,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import org.junit.Test;
import org.openqa.selenium.By;
@@ -72,7 +73,7 @@ public class InterruptUploadTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java
index daff475fc4..aa10027d06 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java
@@ -7,6 +7,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
+import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -54,7 +55,7 @@ public class TestFileUploadTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/TestUploadMIMETypeTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/TestUploadMIMETypeTest.java
index ca32e61234..fddc0727e5 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/TestUploadMIMETypeTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/TestUploadMIMETypeTest.java
@@ -15,6 +15,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.List;
import static com.vaadin.tests.components.upload.TestUploadMIMEType.TEST_MIME_TYPE;
@@ -52,7 +53,7 @@ public class TestUploadMIMETypeTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".pdf");
+ File tempFile = Files.createTempFile("TestFileUpload", ".pdf").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java
index a55029c249..5428a83eee 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java
@@ -6,6 +6,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import org.junit.Test;
import org.openqa.selenium.By;
@@ -46,7 +47,7 @@ public class UploadChangeListenerTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetTest.java
index f54f59141e..0984b3b485 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetTest.java
@@ -4,6 +4,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import org.junit.Test;
import org.openqa.selenium.By;
@@ -40,7 +41,7 @@ public class UploadInTabsheetTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java
index e1d4058904..c1f9031131 100644
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java
+++ b/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java
@@ -7,6 +7,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
+import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -54,7 +55,7 @@ public class TestFileUploadTest extends MultiBrowserTest {
* @throws IOException
*/
private File createTempFile() throws IOException {
- File tempFile = File.createTempFile("TestFileUpload", ".txt");
+ File tempFile = Files.createTempFile("TestFileUpload", ".txt").toFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
writer.write(getTempFileContents());
writer.close();