From 7456a0ebde2efd6cb1080f3fb202e6beac26f3a5 Mon Sep 17 00:00:00 2001 From: lprimak Date: Sun, 12 May 2024 23:23:10 -0500 Subject: [PATCH] bugfix: optimize MR-jar processing --- .../sun/enterprise/loader/ASURLClassLoader.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java index fe088499103..bda5909166e 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ - // Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates] + // Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates] package com.sun.enterprise.loader; @@ -613,12 +613,17 @@ private byte[] loadClassData0(final URLEntry res, final String entryName) { return AccessController.doPrivileged((PrivilegedAction) () -> { try { if (res.isJar) { // It is a jarfile.. - JarFile zip = res.zip; - JarFile jar = new JarFile(res.file, false, JarFile.OPEN_READ, - Runtime.Version.parse(System.getProperty("java.version"))); - JarEntry entry = jar.getJarEntry(entryName); + JarEntry entry; + if (res.zip.isMultiRelease()) { + // optimization, the below op takes time, so avoid it as necessary + entry = res.zip.getJarEntry("META-INF/versions/" + + Runtime.Version.parse(System.getProperty("java.version")) + "/" + + entryName); + } else { + entry = res.zip.getJarEntry(entryName); + } if (entry != null) { - byte[] classData = getClassData(zip.getInputStream(entry)); + byte[] classData = getClassData(res.zip.getInputStream(entry)); res.setProtectionDomain(ASURLClassLoader.this, entry.getCertificates()); return classData; }