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

JrtPath::resolve off-by-one pre-sizing cause for memory pressure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 10
    • None
    • tools
    • b35

      jdk.internal.jrtfs.JrtPath does this:

              StringBuilder sb = new StringBuilder(path.length() + o.path.length());
              sb.append(path);
              if (path.charAt(path.length() - 1) != '/')
                  sb.append('/');
              sb.append(o.path);
              return new JrtPath(jrtfs, sb.toString(), true);

      Since path is always normalized to not have a trailing slash, the pre-sizing is insufficient (which means we'll always resize the array on the sb.append(o.path) step) and the if unnecessary.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: