Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINOR] improvement: Simplify return expression #2375

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading