File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
qa/evil-tests/src/test/java/org/elasticsearch/monitor/os
server/src/main/java/org/elasticsearch/monitor/os Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ public void testOsPrettyName() throws IOException {
3939 final List <String > lines = Files .readAllLines (PathUtils .get ("/etc/os-release" ));
4040 for (final String line : lines ) {
4141 if (line != null && line .startsWith ("PRETTY_NAME=" )) {
42- final Matcher matcher = Pattern .compile ("PRETTY_NAME=(?: \" ?|'?)?([^\" ']+)\\ 1" ).matcher (line .trim ());
42+ final Matcher matcher = Pattern .compile ("PRETTY_NAME=(\" ?|'?)?([^\" ']+)\\ 1" ).matcher (line .trim ());
4343 assert matcher .matches () : line ;
44- assert matcher .groupCount () == 1 : line ;
45- final String prettyName = matcher .group (1 );
44+ assert matcher .groupCount () == 2 : line ;
45+ final String prettyName = matcher .group (2 );
4646 assertThat (osInfo .getPrettyName (), equalTo (prettyName ));
4747 return ;
4848 }
Original file line number Diff line number Diff line change @@ -551,10 +551,10 @@ private String getPrettyName() throws IOException {
551551 if (maybePrettyNameLine .isPresent ()) {
552552 // we trim since some OS contain trailing space, for example, Oracle Linux Server 6.9 has a trailing space after the quote
553553 final String trimmedPrettyNameLine = maybePrettyNameLine .get ().trim ();
554- final Matcher matcher = Pattern .compile ("PRETTY_NAME=(?: \" ?|'?)?([^\" ']+)\\ 1" ).matcher (trimmedPrettyNameLine );
554+ final Matcher matcher = Pattern .compile ("PRETTY_NAME=(\" ?|'?)?([^\" ']+)\\ 1" ).matcher (trimmedPrettyNameLine );
555555 assert matcher .matches () : trimmedPrettyNameLine ;
556- assert matcher .groupCount () == 1 : trimmedPrettyNameLine ;
557- return matcher .group (1 );
556+ assert matcher .groupCount () == 2 : trimmedPrettyNameLine ;
557+ return matcher .group (2 );
558558 } else {
559559 return Constants .OS_NAME ;
560560 }
You can’t perform that action at this time.
0 commit comments