Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1066 from kishansagathiya/small_fix_5
Browse files Browse the repository at this point in the history
Do empty string checks with .isEmpty() everywhere
  • Loading branch information
zilm13 authored May 7, 2018
2 parents 161b2a1 + 4d9edbd commit 4cdc799
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected RocksDbDataSource rocksDbDataSource() {
public void fastSyncCleanUp() {
byte[] fastsyncStageBytes = blockchainDB().get(FastSyncManager.FASTSYNC_DB_KEY_SYNC_STAGE);
if (fastsyncStageBytes == null) return; // no uncompleted fast sync
if (!systemProperties().blocksLoader().equals("")) return; // blocks loader enabled
if (!systemProperties().blocksLoader().isEmpty()) return; // blocks loader enabled

EthereumListener.SyncState syncStage = EthereumListener.SyncState.values()[fastsyncStageBytes[0]];

Expand Down
2 changes: 1 addition & 1 deletion ethereumj-core/src/main/java/org/ethereum/util/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public boolean isEmpty() {
if (isNull()) return true;
if (isBytes() && asBytes().length == 0) return true;
if (isList() && asList().isEmpty()) return true;
if (isString() && asString().equals("")) return true;
if (isString() && asString().isEmpty()) return true;

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class GitHubJSONTestSuite {


protected static void runGitHubJsonVMTest(String json, String testName) throws ParseException {
Assume.assumeFalse("Online test is not available", json.equals(""));
Assume.assumeFalse("Online test is not available", json.isEmpty());

JSONParser parser = new JSONParser();
JSONObject testSuiteObj = (JSONObject) parser.parse(json);
Expand Down Expand Up @@ -83,7 +83,7 @@ protected static void runGitHubJsonVMTest(String json, String testName) throws P
}

public static void runGitHubJsonVMTest(String json) throws ParseException {
Assume.assumeFalse("Online test is not available", json.equals(""));
Assume.assumeFalse("Online test is not available", json.isEmpty());

JSONParser parser = new JSONParser();
JSONObject testSuiteObj = (JSONObject) parser.parse(json);
Expand Down Expand Up @@ -124,7 +124,7 @@ protected static void runGitHubJsonSingleBlockTest(String json, String testName)


protected static void runGitHubJsonBlockTest(String json, Set<String> excluded) throws ParseException, IOException {
Assume.assumeFalse("Online test is not available", json.equals(""));
Assume.assumeFalse("Online test is not available", json.isEmpty());

BlockTestSuite testSuite = new BlockTestSuite(json);
Set<String> testCases = testSuite.getTestCases().keySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
public class Utils {

public static byte[] parseVarData(String data){
if (data == null || data.equals("")) return EMPTY_BYTE_ARRAY;
if (data == null || data.isEmpty()) return EMPTY_BYTE_ARRAY;

byte[] bytes;
if (data.startsWith("0x")) {
data = data.substring(2);
if (data.equals("")) return EMPTY_BYTE_ARRAY;
if (data.isEmpty()) return EMPTY_BYTE_ARRAY;

if (data.length() % 2 == 1) data = "0" + data;

Expand All @@ -64,24 +64,24 @@ public static byte[] parseData(String data) {

public static byte[] parseNumericData(String data){

if (data == null || data.equals("")) return EMPTY_BYTE_ARRAY;
if (data == null || data.isEmpty()) return EMPTY_BYTE_ARRAY;
byte[] dataB = unifiedNumericToBigInteger(data).toByteArray();
return ByteUtil.stripLeadingZeroes(dataB);
}

public static long parseLong(String data) {
boolean hex = data.startsWith("0x");
if (hex) data = data.substring(2);
if (data.equals("")) return 0;
if (data.isEmpty()) return 0;
return new BigInteger(data, hex ? 16 : 10).longValue();
}

public static byte parseByte(String data) {
if (data.startsWith("0x")) {
data = data.substring(2);
return data.equals("") ? 0 : Byte.parseByte(data, 16);
return data.isEmpty() ? 0 : Byte.parseByte(data, 16);
} else
return data.equals("") ? 0 : Byte.parseByte(data);
return data.isEmpty() ? 0 : Byte.parseByte(data);
}


Expand Down

0 comments on commit 4cdc799

Please sign in to comment.