Skip to content

Commit

Permalink
run spotless apply to handle PR test failure
Browse files Browse the repository at this point in the history
Signed-off-by: Bhanu Pulluri <[email protected]>
  • Loading branch information
Bhanu Pulluri committed Sep 14, 2024
1 parent 56c1bcd commit 793dbee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
27 changes: 12 additions & 15 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@
import java.net.URI;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.UserPrincipal;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -230,11 +233,6 @@
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.nio.file.Files;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.UserPrincipal;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
Expand Down Expand Up @@ -388,9 +386,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Optional<String> identityString = Optional.empty();

@Option(
names = "--print-paths-and-exit",
description = "Print the configured paths and exit without starting the node."
)
names = "--print-paths-and-exit",
description = "Print the configured paths and exit without starting the node.")
private final Boolean printPathsAndExit = false;

// P2P Discovery Option Group
Expand Down Expand Up @@ -1107,7 +1104,7 @@ public void run() {
if (printPathsAndExit) {
// Print configured paths requiring read/write permissions to be adjusted
checkPermissionsAndPrintPaths();
System.exit(0); // Exit before any services are started
System.exit(0); // Exit before any services are started
}

// set merge config on the basis of genesis config
Expand Down Expand Up @@ -1161,17 +1158,16 @@ private void checkPermissionsAndPrintPaths() {

// Check permissions for genesis file
try {
if(genesisFile != null) {
checkPermissions(genesisFile.toPath(),"besu", true);
if (genesisFile != null) {
checkPermissions(genesisFile.toPath(), "besu", true);
}
} catch (Exception e) {
System.out.println("Error: Failed checking genesis file: Reason: " + e.getMessage());
}
}


// Helper method to check permissions on a given path
private void checkPermissions(final Path path,final String besuUser, final boolean readOnly) {
private void checkPermissions(final Path path, final String besuUser, final boolean readOnly) {
try {
// Get the permissions of the file
// check if besu user is the owner - get owner permissions if yes
Expand All @@ -1180,7 +1176,7 @@ private void checkPermissions(final Path path,final String besuUser, final boole

// Get the owner of the file or directory
UserPrincipal owner = Files.getOwner(path);
boolean hasReadPermission , hasWritePermission;
boolean hasReadPermission, hasWritePermission;

// Get file permissions
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(path);
Expand All @@ -1203,7 +1199,8 @@ private void checkPermissions(final Path path,final String besuUser, final boole
}
} catch (Exception e) {
// Do nothing upon catching an error
System.out.println("Error: Failed to check permissions for path: '" + path + "'. Reason: " + e.getMessage());
System.out.println(
"Error: Failed to check permissions for path: '" + path + "'. Reason: " + e.getMessage());
}
}

Expand Down
1 change: 0 additions & 1 deletion besu/src/main/scripts/besu-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
## SPDX-License-Identifier: Apache-2.0
##


# Run Besu first to get paths needing permission adjustment
output=$(/opt/besu/bin/besu --print-paths-and-exit "$@")

Expand Down

0 comments on commit 793dbee

Please sign in to comment.