Skip to content

Commit

Permalink
Use Files.writeString API to write string in file
Browse files Browse the repository at this point in the history
  • Loading branch information
krvikash authored and ebyhr committed Dec 22, 2022
1 parent 1046795 commit e1be8ce
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected HiveMinioDataLake createHiveMinioDataLake()
FileAttribute<Set<PosixFilePermission>> posixFilePermissions = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--"));
Path hadoopCoreSiteXmlTempFile = Files.createTempFile("core-site", ".xml", posixFilePermissions);
hadoopCoreSiteXmlTempFile.toFile().deleteOnExit();
Files.write(hadoopCoreSiteXmlTempFile, abfsSpecificCoreSiteXmlContent.getBytes(UTF_8));
Files.writeString(hadoopCoreSiteXmlTempFile, abfsSpecificCoreSiteXmlContent);

HiveMinioDataLake hiveMinioDataLake = new HiveMinioDataLake(
bucketName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private Path createHadoopCoreSiteXmlTempFileWithAbfsSettings()
FileAttribute<Set<PosixFilePermission>> posixFilePermissions = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--"));
Path coreSiteXml = Files.createTempFile("core-site", ".xml", posixFilePermissions);
coreSiteXml.toFile().deleteOnExit();
Files.write(coreSiteXml, abfsSpecificCoreSiteXmlContent.getBytes(UTF_8));
Files.writeString(coreSiteXml, abfsSpecificCoreSiteXmlContent);

return coreSiteXml;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.nio.file.Files;

import static com.google.common.collect.Iterables.getOnlyElement;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class TestDeltaLakePlugin
Expand Down Expand Up @@ -197,7 +196,7 @@ public void testFileBasedAccessControl()
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
File tempFile = File.createTempFile("test-delta-lake-plugin-access-control", ".json");
tempFile.deleteOnExit();
Files.write(tempFile.toPath(), "{}".getBytes(UTF_8));
Files.writeString(tempFile.toPath(), "{}");

factory.create(
"test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import static io.trino.testing.TestingConnectorSession.SESSION;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.hive.metastore.TableType.EXTERNAL_TABLE;
import static org.apache.hadoop.hive.metastore.TableType.VIRTUAL_VIEW;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -266,8 +267,8 @@ private void createTransactionLog(String deltaLakeTableLocation)
{
File deltaTableLogLocation = new File(new File(new URI(deltaLakeTableLocation)), "_delta_log");
verify(deltaTableLogLocation.mkdirs(), "mkdirs() on '%s' failed", deltaTableLogLocation);
byte[] entry = Resources.toByteArray(Resources.getResource("deltalake/person/_delta_log/00000000000000000000.json"));
Files.write(new File(deltaTableLogLocation, "00000000000000000000.json").toPath(), entry);
String entry = Resources.toString(Resources.getResource("deltalake/person/_delta_log/00000000000000000000.json"), UTF_8);
Files.writeString(new File(deltaTableLogLocation, "00000000000000000000.json").toPath(), entry);
}

private String tableLocation(SchemaTableName tableName)
Expand Down

0 comments on commit e1be8ce

Please sign in to comment.