You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/01/27 08:14:06 UTC

[GitHub] [cassandra] nvharikrishna commented on a change in pull request #1381: [CASSANDRA-17126] Removing usages of java.io.File and others from tests

nvharikrishna commented on a change in pull request #1381:
URL: https://github.com/apache/cassandra/pull/1381#discussion_r793351003



##########
File path: test/unit/org/apache/cassandra/Util.java
##########
@@ -850,4 +853,25 @@ public static void setUpgradeFromVersion(String version)
         }
         Gossiper.instance.expireUpgradeFromVersion();
     }
+
+    /**
+     * Sets the length of the file to given size. File will be created if not exist.
+     * @param file file for which length needs to be set
+     * @param size new szie
+     * @throws IOException on any I/O error.
+     */
+    public static void setFileLength(File file, long size) throws IOException
+    {
+        try(FileChannel fileChannel = file.newReadWriteChannel()) {
+            if(file.length() >= size)
+            {
+                fileChannel.truncate(size);
+            }
+            else
+            {
+                fileChannel.position(size -1);

Review comment:
       done

##########
File path: test/long/org/apache/cassandra/cql3/CorruptionTest.java
##########
@@ -145,10 +145,10 @@ private void dumpKeys(byte[] putdata, byte[] getdata) throws IOException {
                     String basename = "bad-data-tid" + Thread.currentThread().getId();
                     File put = new File(basename+"-put");
                     File get = new File(basename+"-get");
-                    try(FileWriter pw = new FileWriter(put.toJavaIOFile())) {
+                    try(FileWriter pw = put.newWriter(File.WriteMode.OVERWRITE)) {

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org