Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8311514

Incorrect regex in TestMetaSpaceLog.java

XMLWordPrintable

    • gc
    • b06
    • generic
    • generic

        The regex used in gc/logging/TestMetaSpaceLog.java to capture the metaspace size change doesn't write correctly.

        It is written like this:
        metaSpaceRegexp = Pattern.compile(".*Metaspace: ([0-9]+).*->([0-9]+).*");

        For the following log,
        [gc,metaspace ] GC(0) Metaspace: 11895K(14208K)->11895K(14208K) NonClass: 10552K(12544K)->10552K(12544K) Class: 1343K(1664K)->1343K(1664K)

        It intends to capture the metaspace size before and after the GC, which is the first 11895 and second 11895 separately. But as this regex is greedy, it will capture the first 11895 and the last 1343.

        This mistake might cause the test always to succeed.

        It might be changed to:
        metaSpaceRegexp = Pattern.compile(".*Metaspace: ([0-9]+)K\\([0-9]+K\\)->([0-9]+)K\\([0-9]+K\\).*");

              dqu Daohan Qu
              dqu Daohan Qu
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: