Author: eevans
Date: Thu Sep 2 19:02:29 2010
New Revision: 992057
URL: http://svn.apache.org/viewvc?rev=992057&view=rev
Log:
cleaned up avro execption handling
Patch by Nirmal Ranganathan (w/ minor change); reviewed by eevans
Modified:
cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java
cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
Modified:
cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java?rev=992057&r1=992056&r2=992057&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java
Thu Sep 2 19:02:29 2010
@@ -135,9 +135,9 @@ class ErrorFactory
return newInvalidRequestException(new Utf8(why));
}
- static InvalidRequestException
newInvalidRequestException(org.apache.cassandra.thrift.InvalidRequestException
e)
+ static InvalidRequestException newInvalidRequestException(Throwable e)
{
- InvalidRequestException exception = newInvalidRequestException(e.why);
+ InvalidRequestException exception =
newInvalidRequestException(e.getMessage());
exception.initCause(e);
return exception;
}
Modified:
cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java?rev=992057&r1=992056&r2=992057&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Thu
Sep 2 19:02:29 2010
@@ -180,11 +180,11 @@ public class CassandraServer implements
// which throw Thrift exceptions directly.
catch (org.apache.cassandra.thrift.UnavailableException e)
{
- throw new UnavailableException();
+ throw newUnavailableException(e);
}
catch (org.apache.cassandra.thrift.InvalidRequestException e)
{
- throw new InvalidRequestException();
+ throw newInvalidRequestException(e);
}
finally
{
@@ -450,7 +450,7 @@ public class CassandraServer implements
}
catch (org.apache.cassandra.thrift.UnavailableException thriftE)
{
- throw new UnavailableException();
+ throw newUnavailableException(thriftE);
}
finally
{
@@ -592,15 +592,11 @@ public class CassandraServer implements
// this means call() threw an exception. deal with it directly.
if (e.getCause() != null)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getCause().getMessage());
- ex.initCause(e.getCause());
- throw ex;
+ throw newInvalidRequestException(e.getCause());
}
else
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
}
}
@@ -682,21 +678,15 @@ public class CassandraServer implements
}
catch (ClassNotFoundException e)
{
- InvalidRequestException ire =
newInvalidRequestException(e.getMessage());
- ire.initCause(e);
- throw ire;
+ throw newInvalidRequestException(e);
}
catch (ConfigurationException e)
{
- InvalidRequestException ire =
newInvalidRequestException(e.getMessage());
- ire.initCause(e);
- throw ire;
+ throw newInvalidRequestException(e);
}
catch (IOException e)
{
- InvalidRequestException ire =
newInvalidRequestException(e.getMessage());
- ire.initCause(e);
- throw ire;
+ throw newInvalidRequestException(e);
}
}
@@ -710,15 +700,11 @@ public class CassandraServer implements
return DatabaseDescriptor.getDefsVersion().toString();
} catch (ConfigurationException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
catch (IOException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
}
@@ -886,15 +872,11 @@ public class CassandraServer implements
}
catch (ConfigurationException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
catch (IOException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
}
@@ -910,15 +892,11 @@ public class CassandraServer implements
}
catch (ConfigurationException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
catch (IOException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
}
@@ -935,15 +913,11 @@ public class CassandraServer implements
}
catch (ConfigurationException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
catch (IOException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
}
@@ -960,15 +934,11 @@ public class CassandraServer implements
}
catch (ConfigurationException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
catch (IOException e)
{
- InvalidRequestException ex =
newInvalidRequestException(e.getMessage());
- ex.initCause(e);
- throw ex;
+ throw newInvalidRequestException(e);
}
}
@@ -1016,7 +986,7 @@ public class CassandraServer implements
public List<TokenRange> describe_ring(CharSequence keyspace) throws
AvroRemoteException, InvalidRequestException
{
- if (keyspace == null ||
!DatabaseDescriptor.getNonSystemTables().contains(keyspace))
+ if (keyspace == null || keyspace.toString().equals(Table.SYSTEM_TABLE))
throw newInvalidRequestException("There is no ring for the
keyspace: " + keyspace);
List<TokenRange> ranges = new ArrayList<TokenRange>();
Token.TokenFactory<?> tf =
StorageService.getPartitioner().getTokenFactory();