Skip to content

Commit 55058aa

Browse files
authored
Code scan fixes (apache#9)
1 parent 618d6a5 commit 55058aa

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

src/java/org/apache/cassandra/db/memtable/PersistentMemoryMemtable.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ public long partitionKeysSize()
400400

401401
public boolean shouldSwitch(ColumnFamilyStore.FlushReason reason)
402402
{
403-
System.out.println("Reason : "+ reason);
404403
// We want to avoid all flushing.
405404
switch (reason)
406405
{
@@ -483,21 +482,19 @@ public void performSnapshot(String snapshotName)
483482
Path src = Paths.get(System.getProperty("pmem_path") + "/" + tableMetaId);
484483
String dest = DatabaseDescriptor.getRawConfig().data_file_directories[0] + "/" + metadata.keyspace + "/" + metadata.name + "-" + tableMetaId + "/snapshots/" + snapshotName;
485484

486-
try
487-
{
485+
try {
488486
Files.createDirectories(Paths.get(dest));
489-
Files.walk(src)
490-
.forEach(source -> {
491-
try
492-
{
493-
Files.copy(source, Paths.get(dest).resolve(src.relativize(source)),
494-
java.nio.file.StandardCopyOption.REPLACE_EXISTING);
495-
}
496-
catch (IOException e)
497-
{
498-
throw new IOError(e);
499-
}
500-
});
487+
try (Stream<Path> pathStream = Files.walk(src)) {
488+
pathStream
489+
.forEach(source -> {
490+
try {
491+
Files.copy(source, Paths.get(dest).resolve(src.relativize(source)),
492+
java.nio.file.StandardCopyOption.REPLACE_EXISTING);
493+
} catch (IOException e) {
494+
throw new IOError(e);
495+
}
496+
});
497+
}
501498
}
502499
catch (Exception e)
503500
{
@@ -507,6 +504,7 @@ public void performSnapshot(String snapshotName)
507504
{
508505
writeLock.compareAndSet(true, false);
509506
}
507+
510508
}
511509

512510
@Override

src/java/org/apache/cassandra/db/memtable/pmem/MemtableImporter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ private List<String> restoreSnapshotData(Set<String> srcPath, String dest)
5656
List<String> failedSnapshotTasks = new ArrayList<String>();
5757
for (String src : srcPath)
5858
{
59-
try
60-
{
61-
Stream<Path> walk = Files.walk(Paths.get(src));
62-
walk
59+
try (Stream<Path> pathStream = Files.walk(Paths.get(src))) {
60+
pathStream
6361
.filter(p -> !Files.isDirectory(p) && (p.toString().endsWith(".pmem") || p.toString().endsWith(".set") ))
6462
.forEach(f -> {
6563
try {

0 commit comments

Comments
 (0)