Skip to content

Commit

Permalink
[Minor] Improve return boolean expression
Browse files Browse the repository at this point in the history
  • Loading branch information
summaryzb committed Mar 4, 2025
1 parent 413c852 commit aa4a1ec
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,8 @@ public boolean resetStageAttemptIfNecessary(int stageAttemptNumber) {
this.isShuffleServerAssignmented = false;
this.isClearedMapTrackerBlock = false;
return false;
} else if (this.stageAttemptNumber > stageAttemptNumber) {
return true;
}
return false;
return this.stageAttemptNumber > stageAttemptNumber;
});
}

Expand Down Expand Up @@ -468,15 +466,10 @@ public boolean incWriteFailureForShuffleServer(

public boolean isNeedReassignForLastStageNumber(int lastStageAttemptNumber) {
return withReadLock(
() -> {
if (isStageNeedRetry
&& !isShuffleServerAssignmented
&& stageAttemptNumber == lastStageAttemptNumber - 1) {
return true;
} else {
return false;
}
});
() ->
isStageNeedRetry
&& !isShuffleServerAssignmented
&& stageAttemptNumber == lastStageAttemptNumber - 1);
}

public void setShuffleServerAssignmented(boolean isAssignmented) {
Expand All @@ -496,10 +489,7 @@ public void setClearedMapTrackerBlock(boolean isCleared) {
}

public boolean isClearedMapTrackerBlock() {
return withReadLock(
() -> {
return isClearedMapTrackerBlock;
});
return withReadLock(() -> isClearedMapTrackerBlock);
}
}

Expand Down Expand Up @@ -583,11 +573,7 @@ public boolean currentPartitionIsFetchFailed(
if (this.stageAttempt != stageAttempt) {
return false;
} else {
if (this.partitions[partition] >= shuffleManager.getMaxFetchFailures()) {
return true;
} else {
return false;
}
return this.partitions[partition] >= shuffleManager.getMaxFetchFailures();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ private List<CompletableFuture<Boolean>> getFutures(boolean fail) {
LOGGER.info("Finished index: " + index);
return true;
}
if (fail && index == 1) {
return false;
}
return true;
return !fail || index != 1;
},
executorService);
futures.add(future);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ public class JavaUtils {
private static final String JAVA_9 = "JAVA_9";

public static boolean isJavaVersionAtLeastJava9() {
if (Enums.getIfPresent(JavaVersion.class, JAVA_9).isPresent()
&& SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)) {
return true;
} else {
return false;
}
return Enums.getIfPresent(JavaVersion.class, JAVA_9).isPresent()
&& SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9);
}

/** Closes the given object, ignoring IOExceptions. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,7 @@ boolean checkStorageReadAndWrite() {
} catch (Exception e) {
LOG.error("Storage read and write error. Storage dir: {}", storageDir, e);
// avoid check bad track failure due to lack of disk space
if (e.getMessage() != null && DEVICE_NO_SPACE_ERROR_MESSAGE.equals(e.getMessage())) {
return true;
}
return false;
return e.getMessage() != null && DEVICE_NO_SPACE_ERROR_MESSAGE.equals(e.getMessage());
} finally {
try {
FileUtils.deleteDirectory(checkDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ public void startHeartBeat() {

@VisibleForTesting
public boolean sendHeartBeat(RssSendHeartBeatRequest request) {
if (coordinatorClient.sendHeartBeat(request).getStatusCode() == StatusCode.SUCCESS) {
return true;
}
return false;
return coordinatorClient.sendHeartBeat(request).getStatusCode() == StatusCode.SUCCESS;
}

public long getHeartBeatInterval() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ public boolean canWrite(ShuffleDataFlushEvent event) {
try {
Storage storage = selectStorage(event);
// if storage is null, appId may not be registered
if (storage == null || !storage.canWrite()) {
return false;
}
return true;
return storage != null && storage.canWrite();
} catch (Exception e) {
LOG.warn("Exception happened when select storage", e);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ boolean checkStorageReadAndWrite() {
throw new IOException("mock");
}
} catch (Exception e) {
if (e.getMessage() != null && DEVICE_NO_SPACE_ERROR_MESSAGE.equals(e.getMessage())) {
return true;
}
return false;
return e.getMessage() != null && DEVICE_NO_SPACE_ERROR_MESSAGE.equals(e.getMessage());
} finally {
try {
FileUtils.deleteDirectory(checkDir);
Expand Down

0 comments on commit aa4a1ec

Please sign in to comment.