cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/4] git commit: clean up "if" style
Date Sat, 28 Jul 2012 14:47:14 GMT
Updated Branches:
  refs/heads/cassandra-1.1 96075b31c -> 0819ad144
  refs/heads/trunk 3d23188a0 -> 7d857e68a


clean up "if" style


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

Branch: refs/heads/trunk
Commit: 7d857e68a484410140e8ed7ada0e16553972e87a
Parents: f223f54
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Sat Jul 28 09:45:16 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Sat Jul 28 09:45:16 2012 -0500

----------------------------------------------------------------------
 .../apache/cassandra/auth/SimpleAuthenticator.java |    8 ++++----
 .../org/apache/cassandra/config/CFMetaData.java    |   14 +++++++-------
 .../db/compaction/LeveledCompactionStrategy.java   |    2 +-
 .../db/marshal/AbstractCompositeType.java          |    2 +-
 .../org/apache/cassandra/locator/Ec2Snitch.java    |    2 +-
 .../service/SocketSessionManagementService.java    |    4 ++--
 .../org/apache/cassandra/utils/ByteBufferUtil.java |   13 +++++--------
 7 files changed, 21 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/examples/simple_authentication/src/org/apache/cassandra/auth/SimpleAuthenticator.java
----------------------------------------------------------------------
diff --git a/examples/simple_authentication/src/org/apache/cassandra/auth/SimpleAuthenticator.java
b/examples/simple_authentication/src/org/apache/cassandra/auth/SimpleAuthenticator.java
index 254cd5d..c8d63b7 100644
--- a/examples/simple_authentication/src/org/apache/cassandra/auth/SimpleAuthenticator.java
+++ b/examples/simple_authentication/src/org/apache/cassandra/auth/SimpleAuthenticator.java
@@ -58,7 +58,7 @@ public class SimpleAuthenticator implements IAuthenticator
         String pmode_plain = System.getProperty(PMODE_PROPERTY);
         PasswordMode mode = PasswordMode.PLAIN;
 
-        if (null != pmode_plain)
+        if (pmode_plain != null)
         {
             try
             {
@@ -80,14 +80,14 @@ public class SimpleAuthenticator implements IAuthenticator
 
         String username = null;
         CharSequence user = credentials.get(USERNAME_KEY);
-        if (null == user) 
+        if (user == null)
             throw new AuthenticationException("Authentication request was missing the required
key '" + USERNAME_KEY + "'");
         else
             username = user.toString();
 
         String password = null;
         CharSequence pass = credentials.get(PASSWORD_KEY);
-        if (null == pass) 
+        if (pass == null)
             throw new AuthenticationException("Authentication request was missing the required
key '" + PASSWORD_KEY + "'");
         else
             password = pass.toString();
@@ -102,7 +102,7 @@ public class SimpleAuthenticator implements IAuthenticator
             props.load(in);
 
             // note we keep the message here and for the wrong password exactly the same
to prevent attackers from guessing what users are valid
-            if (null == props.getProperty(username)) throw new AuthenticationException(authenticationErrorMessage(mode,
username));
+            if (props.getProperty(username) == null) throw new AuthenticationException(authenticationErrorMessage(mode,
username));
             switch (mode)
             {
                 case PLAIN:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 4ff7d2d..4e5b6e3 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -99,11 +99,11 @@ public final class CFMetaData
 
     // new-style schema
     public static final CFMetaData SchemaKeyspacesCf = compile(8, "CREATE TABLE " + SystemTable.SCHEMA_KEYSPACES_CF
+ "("
-                                                                 + "keyspace_name text PRIMARY
KEY,"
-                                                                 + "durable_writes boolean,"
-                                                                 + "strategy_class text,"
-                                                                 + "strategy_options text"
-                                                                 + ") WITH COMPACT STORAGE
AND COMMENT='keyspace definitions' AND gc_grace_seconds=8640");
+                                                                  + "keyspace_name text PRIMARY
KEY,"
+                                                                  + "durable_writes boolean,"
+                                                                  + "strategy_class text,"
+                                                                  + "strategy_options text"
+                                                                  + ") WITH COMPACT STORAGE
AND COMMENT='keyspace definitions' AND gc_grace_seconds=8640");
     public static final CFMetaData SchemaColumnFamiliesCf = compile(9, "CREATE TABLE " +
SystemTable.SCHEMA_COLUMNFAMILIES_CF + "("
                                                                      + "keyspace_name text,"
                                                                      + "columnfamily_name
text,"
@@ -614,9 +614,9 @@ public final class CFMetaData
             cf_def.setMin_compaction_threshold(CFMetaData.DEFAULT_MIN_COMPACTION_THRESHOLD);
         if (!cf_def.isSetMax_compaction_threshold())
             cf_def.setMax_compaction_threshold(CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD);
-        if (null == cf_def.compaction_strategy)
+        if (cf_def.compaction_strategy == null)
             cf_def.compaction_strategy = DEFAULT_COMPACTION_STRATEGY_CLASS;
-        if (null == cf_def.compaction_strategy_options)
+        if (cf_def.compaction_strategy_options == null)
             cf_def.compaction_strategy_options = Collections.emptyMap();
         if (!cf_def.isSetCompression_options())
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
index c352832..ce352da 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
@@ -55,7 +55,7 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
implem
         if (options != null)
         {
             String value = options.containsKey(SSTABLE_SIZE_OPTION) ? options.get(SSTABLE_SIZE_OPTION)
: null;
-            if (null != value)
+            if (value != null)
             {
                 try
                 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
index e138b67..ea24ab1 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -61,7 +61,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
 
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
-        if (null == o1)
+        if (o1 == null)
             return null == o2 ? 0 : -1;
 
         ByteBuffer bb1 = o1.duplicate();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/src/java/org/apache/cassandra/locator/Ec2Snitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/Ec2Snitch.java b/src/java/org/apache/cassandra/locator/Ec2Snitch.java
index 66ca1f1..5eb15a5 100644
--- a/src/java/org/apache/cassandra/locator/Ec2Snitch.java
+++ b/src/java/org/apache/cassandra/locator/Ec2Snitch.java
@@ -91,7 +91,7 @@ public class Ec2Snitch extends AbstractNetworkTopologySnitch
         if (endpoint.equals(FBUtilities.getBroadcastAddress()))
             return ec2zone;
         EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
-        if (null == state || null == state.getApplicationState(ApplicationState.RACK))
+        if (state == null || state.getApplicationState(ApplicationState.RACK) == null)
             return DEFAULT_RACK;
         return state.getApplicationState(ApplicationState.RACK).value;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/SocketSessionManagementService.java b/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
index ad42a3e..7cf1703 100644
--- a/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
+++ b/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
@@ -30,7 +30,7 @@ public class SocketSessionManagementService
     public ClientState get(SocketAddress key)
     {
         ClientState retval = null;
-        if (null != key)
+        if (key != null)
         {
             retval = activeSocketSessions.get(key);
         }
@@ -39,7 +39,7 @@ public class SocketSessionManagementService
 
     public void put(SocketAddress key, ClientState value)
     {
-        if (null != key && null != value)
+        if (key != null && value != null)
         {
             activeSocketSessions.put(key, value);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d857e68/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/ByteBufferUtil.java b/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
index a13440e..f0b36bf 100644
--- a/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
+++ b/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
@@ -506,20 +506,17 @@ public class ByteBufferUtil
      */
     public static int compareSubArrays(ByteBuffer bytes1, int offset1, ByteBuffer bytes2,
int offset2, int length)
     {
-        if ( null == bytes1 )
-        {
-            if ( null == bytes2) return 0;
-            else return -1;
-        }
-        if (null == bytes2 ) return 1;
+        if (bytes1 == null)
+            return bytes2 == null ? 0 : -1;
+        if (bytes2 == null) return 1;
 
         assert bytes1.limit() >= offset1 + length : "The first byte array isn't long enough
for the specified offset and length.";
         assert bytes2.limit() >= offset2 + length : "The second byte array isn't long
enough for the specified offset and length.";
-        for ( int i = 0; i < length; i++ )
+        for (int i = 0; i < length; i++)
         {
             byte byte1 = bytes1.get(offset1 + i);
             byte byte2 = bytes2.get(offset2 + i);
-            if ( byte1 == byte2 )
+            if (byte1 == byte2)
                 continue;
             // compare non-equal bytes as unsigned
             return (byte1 & 0xFF) < (byte2 & 0xFF) ? -1 : 1;


Mime
View raw message