[ 
https://issues.apache.org/jira/browse/CASSANDRA-5587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julien Aymé updated CASSANDRA-5587:
-----------------------------------

    Comment: was deleted

(was: diff --git a/src/java/org/apache/cassandra/io/sstable/SSTable.java 
b/src/java/org/apache/cassandra/io/sstable/SSTable.java
index c7486ba..47b2612 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTable.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTable.java
@@ -191,7 +191,16 @@ public abstract class SSTable
      */
     public static Pair<Descriptor,Component> tryComponentFromFilename(File 
dir, String name)
     {
-        return Component.fromFilename(dir, name);
+        try
+        {
+            return Component.fromFilename(dir, name);
+        }
+        catch (NoSuchElementException e)
+        {
+            // A NoSuchElementException is thrown if the name does not match 
the Descriptor format
+            // This is the less impacting change (all calls to this method 
test for null return)
+            return null;
+        }
     }
 
     /**
diff --git a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java 
b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
index 007e0ca..9d31d7e 100644
--- a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
@@ -21,6 +21,7 @@ package org.apache.cassandra.io.sstable;
  */
 
 import org.apache.cassandra.utils.FilterFactory;
+import org.apache.cassandra.utils.Pair;
 import org.junit.Test;
 import static org.junit.Assert.*;
 
@@ -64,4 +65,11 @@ public class DescriptorTest
         assertEquals("ia", desc.version.toString());
         assertEquals(desc.version.filterType, FilterFactory.Type.MURMUR3);
     }
+
+    @Test
+    public void testInvalidnameFormat()
+    {
+        Pair<Descriptor, Component> p = SSTable.tryComponentFromFilename(null, 
"snapshot");
+        assertNull(p);
+    }
 }
)
    
> BulkLoader fails with NoSuchElementException
> --------------------------------------------
>
>                 Key: CASSANDRA-5587
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5587
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions: 1.2.4, 1.2.5
>            Reporter: Julien Aymé
>              Labels: patch
>         Attachments: cassandra-1.2-5587.txt
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> When using BulkLoader tool (sstableloader command) to transfer data from a 
> cluster to another, 
> a java.util.NoSuchElementException is thrown whenever the directory contains 
> a "snapshot" sub directory,
> and the bulk load fails.
> The fix should be quite simple:
> Catch any NoSuchElementException thrown in {{SSTableLoader#openSSTables()}}
> The directory structure:
> {noformat}
> user@cassandrasrv01:~$ ls /var/lib/cassandra/data/Keyspace1/CF1/
> Keyspace1-CF1-ib-1872-CompressionInfo.db
> Keyspace1-CF1-ib-1872-Data.db
> Keyspace1-CF1-ib-1872-Filter.db
> Keyspace1-CF1-ib-1872-Index.db
> Keyspace1-CF1-ib-1872-Statistics.db
> Keyspace1-CF1-ib-1872-Summary.db
> Keyspace1-CF1-ib-1872-TOC.txt
> Keyspace1-CF1-ib-2166-CompressionInfo.db
> Keyspace1-CF1-ib-2166-Data.db
> Keyspace1-CF1-ib-2166-Filter.db
> Keyspace1-CF1-ib-2166-Index.db
> Keyspace1-CF1-ib-2166-Statistics.db
> Keyspace1-CF1-ib-2166-Summary.db
> Keyspace1-CF1-ib-2166-TOC.txt
> Keyspace1-CF1-ib-5-CompressionInfo.db
> Keyspace1-CF1-ib-5-Data.db
> Keyspace1-CF1-ib-5-Filter.db
> Keyspace1-CF1-ib-5-Index.db
> Keyspace1-CF1-ib-5-Statistics.db
> Keyspace1-CF1-ib-5-Summary.db
> Keyspace1-CF1-ib-5-TOC.txt
> ...
> snapshots
> {noformat}
> The stacktrace: 
> {noformat}
> user@cassandrasrv01:~$ ./cassandra/bin/sstableloader -v --debug -d 
> cassandrabck01 /var/lib/cassandra/data/Keyspace1/CF1/
> null
> java.util.NoSuchElementException
>         at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
>         at 
> org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:265)
>         at 
> org.apache.cassandra.io.sstable.Component.fromFilename(Component.java:122)
>         at 
> org.apache.cassandra.io.sstable.SSTable.tryComponentFromFilename(SSTable.java:194)
>         at 
> org.apache.cassandra.io.sstable.SSTableLoader$1.accept(SSTableLoader.java:71)
>         at java.io.File.list(File.java:1087)
>         at 
> org.apache.cassandra.io.sstable.SSTableLoader.openSSTables(SSTableLoader.java:67)
>         at 
> org.apache.cassandra.io.sstable.SSTableLoader.stream(SSTableLoader.java:119)
>         at org.apache.cassandra.tools.BulkLoader.main(BulkLoader.java:67)
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to