@@ -769,6 +769,9 @@ private Map<String, String> getESEnvironment() {
769
769
.map (p -> p .replace ("${ES_PATH_CONF}" , configFile .getParent ().toString ()))
770
770
.collect (Collectors .joining (" " ));
771
771
}
772
+ if (systemProperties .containsKey ("io.netty.leakDetection.level" ) == false ) {
773
+ systemPropertiesString = systemPropertiesString + " -Dio.netty.leakDetection.level=paranoid" ;
774
+ }
772
775
String jvmArgsString = "" ;
773
776
if (jvmArgs .isEmpty () == false ) {
774
777
jvmArgsString = " " + jvmArgs .stream ().peek (argument -> {
@@ -921,10 +924,6 @@ public synchronized void stop(boolean tailLogs) {
921
924
// Test clusters are not reused, don't spend time on a graceful shutdown
922
925
stopHandle (esProcess .toHandle (), true );
923
926
reaper .unregister (toString ());
924
- if (tailLogs ) {
925
- logFileContents ("Standard output of node" , esStdoutFile );
926
- logFileContents ("Standard error of node" , esStderrFile );
927
- }
928
927
esProcess = null ;
929
928
// Clean up the ports file in case this is started again.
930
929
try {
@@ -937,6 +936,8 @@ public synchronized void stop(boolean tailLogs) {
937
936
} catch (IOException e ) {
938
937
throw new UncheckedIOException (e );
939
938
}
939
+ logFileContents ("Standard output of node" , esStdoutFile , tailLogs );
940
+ logFileContents ("Standard error of node" , esStderrFile , tailLogs );
940
941
}
941
942
942
943
@ Override
@@ -989,7 +990,7 @@ private void logProcessInfo(String prefix, ProcessHandle.Info info) {
989
990
);
990
991
}
991
992
992
- private void logFileContents (String description , Path from ) {
993
+ private void logFileContents (String description , Path from , boolean tailLogs ) {
993
994
final Map <String , Integer > errorsAndWarnings = new LinkedHashMap <>();
994
995
LinkedList <String > ring = new LinkedList <>();
995
996
try (LineNumberReader reader = new LineNumberReader (Files .newBufferedReader (from ))) {
@@ -1018,31 +1019,47 @@ private void logFileContents(String description, Path from) {
1018
1019
}
1019
1020
}
1020
1021
} catch (IOException e ) {
1021
- throw new UncheckedIOException ("Failed to tail log " + this , e );
1022
+ if (tailLogs ) {
1023
+ throw new UncheckedIOException ("Failed to tail log " + this , e );
1024
+ }
1025
+ return ;
1022
1026
}
1023
1027
1024
- if (errorsAndWarnings .isEmpty () == false || ring .isEmpty () == false ) {
1025
- LOGGER .error ("\n === {} `{}` ===" , description , this );
1026
- }
1027
- if (errorsAndWarnings .isEmpty () == false ) {
1028
- LOGGER .lifecycle ("\n » ↓ errors and warnings from " + from + " ↓" );
1029
- errorsAndWarnings .forEach ((message , count ) -> {
1030
- LOGGER .lifecycle ("» " + message .replace ("\n " , "\n » " ));
1031
- if (count > 1 ) {
1032
- LOGGER .lifecycle ("» ↑ repeated " + count + " times ↑" );
1033
- }
1034
- });
1028
+ boolean foundNettyLeaks = false ;
1029
+ for (String logLine : errorsAndWarnings .keySet ()) {
1030
+ if (logLine .contains ("ResourceLeakDetector]" )) {
1031
+ tailLogs = true ;
1032
+ foundNettyLeaks = true ;
1033
+ break ;
1034
+ }
1035
1035
}
1036
+ if (tailLogs ) {
1037
+ if (errorsAndWarnings .isEmpty () == false || ring .isEmpty () == false ) {
1038
+ LOGGER .error ("\n === {} `{}` ===" , description , this );
1039
+ }
1040
+ if (errorsAndWarnings .isEmpty () == false ) {
1041
+ LOGGER .lifecycle ("\n » ↓ errors and warnings from " + from + " ↓" );
1042
+ errorsAndWarnings .forEach ((message , count ) -> {
1043
+ LOGGER .lifecycle ("» " + message .replace ("\n " , "\n » " ));
1044
+ if (count > 1 ) {
1045
+ LOGGER .lifecycle ("» ↑ repeated " + count + " times ↑" );
1046
+ }
1047
+ });
1048
+ }
1036
1049
1037
- ring .removeIf (line -> MESSAGES_WE_DONT_CARE_ABOUT .stream ().anyMatch (line ::contains ));
1050
+ ring .removeIf (line -> MESSAGES_WE_DONT_CARE_ABOUT .stream ().anyMatch (line ::contains ));
1038
1051
1039
- if (ring .isEmpty () == false ) {
1040
- LOGGER .lifecycle ("» ↓ last " + TAIL_LOG_MESSAGES_COUNT + " non error or warning messages from " + from + " ↓" );
1041
- ring .forEach (message -> {
1042
- if (errorsAndWarnings .containsKey (normalizeLogLine (message )) == false ) {
1043
- LOGGER .lifecycle ("» " + message .replace ("\n " , "\n » " ));
1044
- }
1045
- });
1052
+ if (ring .isEmpty () == false ) {
1053
+ LOGGER .lifecycle ("» ↓ last " + TAIL_LOG_MESSAGES_COUNT + " non error or warning messages from " + from + " ↓" );
1054
+ ring .forEach (message -> {
1055
+ if (errorsAndWarnings .containsKey (normalizeLogLine (message )) == false ) {
1056
+ LOGGER .lifecycle ("» " + message .replace ("\n " , "\n » " ));
1057
+ }
1058
+ });
1059
+ }
1060
+ }
1061
+ if (foundNettyLeaks ) {
1062
+ throw new TestClustersException ("Found Netty ByteBuf leaks in node logs." );
1046
1063
}
1047
1064
}
1048
1065
0 commit comments