@@ -69,6 +69,7 @@ public class ConfigurationOverviewBuilder {
6969 private boolean isParallelTxProcessingEnabled = false ;
7070 private RocksDBCLIOptions .BlobDBSettings blobDBSettings ;
7171 private Long targetGasLimit ;
72+ private static final String MINIMUM_GLIBC_VERSION = "2.28" ;
7273
7374 /**
7475 * Create a new ConfigurationOverviewBuilder.
@@ -576,22 +577,17 @@ private void detectJemalloc(final List<String> lines) {
576577 * @param glibcVersion the detected glibc version
577578 */
578579 private void checkGlibcVersion (final String glibcVersion ) {
579- if (glibcVersion == null ) {
580- // Cannot determine version, log warning but allow startup
581- logger .warn ("Unable to determine glibc version. Minimum required version is 2.28" );
582- return ;
583- }
580+ if (glibcVersion == null ) {
581+ logger .warn ("Unable to determine glibc version. Minimum required version is {}" , MINIMUM_GLIBC_VERSION );
582+ return ;
583+ }
584584
585- final String minVersion = "2.28" ;
586- if (!isGlibcVersionSufficient (glibcVersion , minVersion )) {
587- logger .error ("Insufficient glibc version detected." );
588- logger .error ("Required: {} or higher" , minVersion );
589- logger .error ("Found: {}" , glibcVersion );
590- logger .error ("Please upgrade your system's glibc to version {} or higher." , minVersion );
591- throw new RuntimeException (
592- "Besu requires glibc version " + minVersion + " or higher. Found: " + glibcVersion );
593- }
585+ if (!isGlibcVersionSufficient (glibcVersion , MINIMUM_GLIBC_VERSION )) {
586+ logger .error ("Insufficient glibc version detected. Required: {} or higher, Found: {}. Please upgrade your system's glibc." , MINIMUM_GLIBC_VERSION , glibcVersion );
587+ throw new RuntimeException (
588+ "Besu requires glibc version " + MINIMUM_GLIBC_VERSION + " or higher. Found: " + glibcVersion );
594589 }
590+ }
595591
596592 /**
597593
@@ -603,27 +599,29 @@ private void checkGlibcVersion(final String glibcVersion) {
603599 */
604600
605601 private boolean isGlibcVersionSufficient (final String current , final String required ) {
606- try {
607- final String [] currentParts = current .split ("\\ ." );
608- final String [] requiredParts = required .split ("\\ ." );
609-
610- for (int i = 0 ; i < Math .min (currentParts .length , requiredParts .length ); i ++) {
611- final int currentNum = Integer .parseInt (currentParts [i ].trim ());
612- final int requiredNum = Integer .parseInt (requiredParts [i ].trim ());
613-
614- if (currentNum > requiredNum ) {
615- return true ;
616- }
617- if (currentNum < requiredNum ) {
618- return false ;
619- }
602+ try {
603+ final String [] currentParts = current .split ("\\ ." );
604+ final String [] requiredParts = required .split ("\\ ." );
605+
606+ final int compareLength = Math .max (currentParts .length , requiredParts .length );
607+
608+ for (int i = 0 ; i < compareLength ; i ++) {
609+ final int currentNum = i < currentParts .length ? Integer .parseInt (currentParts [i ].trim ()) : 0 ;
610+ final int requiredNum = i < requiredParts .length ? Integer .parseInt (requiredParts [i ].trim ()) : 0 ;
611+
612+ if (currentNum > requiredNum ) {
613+ return true ;
614+ }
615+ if (currentNum < requiredNum ) {
616+ return false ;
620617 }
621- return true ; // Versions are equal
622- } catch (final NumberFormatException e ) {
623- logger .warn ("Unable to parse glibc version: {}" , current , e );
624- return true ; // Assume sufficient if unable to parse
625618 }
619+ return true ;
620+ } catch (final NumberFormatException e ) {
621+ logger .warn ("Unable to parse glibc version: {}" , current , e );
622+ return true ;
626623 }
624+ }
627625
628626
629627
0 commit comments