clean up "if" style

This commit is contained in:
Jonathan Ellis 2012-07-28 09:45:16 -05:00
parent f223f5485a
commit 7d857e68a4
7 changed files with 21 additions and 24 deletions

View File

@ -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:

View File

@ -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())
{

View File

@ -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
{

View File

@ -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();

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;