cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [1/3] cassandra git commit: Fixed COVERITY defects for CASSANDRA-7066
Date Wed, 19 Aug 2015 12:39:14 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 d12d2d496 -> 00bcccc8c
  refs/heads/trunk 036f6b77d -> 53e73df65


Fixed COVERITY defects for CASSANDRA-7066


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/00bcccc8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/00bcccc8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/00bcccc8

Branch: refs/heads/cassandra-3.0
Commit: 00bcccc8c9f0c2819c162a49367d5072b0c49de5
Parents: d12d2d4
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Tue Aug 18 08:34:25 2015 +0800
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Wed Aug 19 13:38:22 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cassandra/db/lifecycle/TransactionLog.java   | 4 ++--
 src/java/org/apache/cassandra/io/util/FileUtils.java        | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/00bcccc8/src/java/org/apache/cassandra/db/lifecycle/TransactionLog.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/lifecycle/TransactionLog.java b/src/java/org/apache/cassandra/db/lifecycle/TransactionLog.java
index 4b18749..6bc2eeb 100644
--- a/src/java/org/apache/cassandra/db/lifecycle/TransactionLog.java
+++ b/src/java/org/apache/cassandra/db/lifecycle/TransactionLog.java
@@ -228,7 +228,7 @@ public class TransactionLog extends Transactional.AbstractTransactional
implemen
 
         public byte[] getBytes()
         {
-            return record.getBytes();
+            return record.getBytes(FileUtils.CHARSET);
         }
 
         public boolean verify(String parentFolder, boolean lastRecordIsCorrupt)
@@ -360,7 +360,7 @@ public class TransactionLog extends Transactional.AbstractTransactional
implemen
                 return Record.make(line, isLast);
             }
 
-            byte[] bytes = matcher.group(1).getBytes();
+            byte[] bytes = matcher.group(1).getBytes(FileUtils.CHARSET);
             checksum.update(bytes, 0, bytes.length);
 
             if (checksum.getValue() != Long.valueOf(matcher.group(2)))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/00bcccc8/src/java/org/apache/cassandra/io/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/FileUtils.java b/src/java/org/apache/cassandra/io/util/FileUtils.java
index 0ba2307..920eee0 100644
--- a/src/java/org/apache/cassandra/io/util/FileUtils.java
+++ b/src/java/org/apache/cassandra/io/util/FileUtils.java
@@ -21,13 +21,12 @@ import java.io.*;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.*;
 import java.text.DecimalFormat;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 
-import org.apache.cassandra.config.Config;
 import sun.nio.ch.DirectBuffer;
 
 import org.slf4j.Logger;
@@ -49,6 +48,8 @@ import static org.apache.cassandra.utils.Throwables.merge;
 
 public class FileUtils
 {
+    public static final Charset CHARSET = StandardCharsets.UTF_8;
+
     private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
     private static final double KB = 1024d;
     private static final double MB = 1024*1024d;
@@ -601,7 +602,7 @@ public class FileUtils
         {
             Files.write(file.toPath(),
                         Arrays.asList(lines),
-                        Charset.forName("utf-8"),
+                        CHARSET,
                         op);
         }
         catch (IOException ex)
@@ -614,7 +615,7 @@ public class FileUtils
     {
         try
         {
-            return Files.readAllLines(file.toPath(), Charset.forName("utf-8"));
+            return Files.readAllLines(file.toPath(), CHARSET);
         }
         catch (IOException ex)
         {


Mime
View raw message