Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JarEntry.getComment() returns incorrect result from NestedJarFile instances #39166

Closed
ql2023 opened this issue Jan 17, 2024 · 0 comments
Closed
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@ql2023
Copy link

ql2023 commented Jan 17, 2024

spring-boot-loader 3.2.0

test code:

public class NestedJarFileTests {

    public static void main(String[] args) throws IOException {

        try (JarArchiveOutputStream jar = new JarArchiveOutputStream(new FileOutputStream("app.jar"))) {
            jar.putArchiveEntry(new JarArchiveEntry("BOOT-INF"));
            jar.closeArchiveEntry();

            jar.putArchiveEntry(new JarArchiveEntry("BOOT-INF/classes/"));
            jar.closeArchiveEntry();
            for (int i = 0; i < 5; i++) {
                JarArchiveEntry entry = new JarArchiveEntry("BOOT-INF/classes/T" + i + ".class");
                entry.setComment("T" + i);
                jar.putArchiveEntry(entry);
                jar.write(UUID.randomUUID().toString().getBytes());
                jar.closeArchiveEntry();
            }
        }

        try (JarFile jf = new JarFile(new File("app.jar"))) {
            Enumeration<JarEntry> entries = jf.entries();
            while (entries.hasMoreElements()) {
                JarEntry entry = entries.nextElement();
                System.out.printf("entry=%s, comment=%s%n", entry.getName(), entry.getComment());
            }
        }

        try (NestedJarFile jf = new NestedJarFile(new File("app.jar"), "BOOT-INF/classes/")) {
            Enumeration<JarEntry> entries = jf.entries();
            while (entries.hasMoreElements()) {
                JarEntry entry = entries.nextElement();
                System.out.printf("entry=%s, comment=%s%n", entry.getName(), entry.getComment());
            }
        }
    }
}

output:

entry=BOOT-INF, comment=null
entry=BOOT-INF/classes/, comment=null
entry=BOOT-INF/classes/T0.class, comment=T0
entry=BOOT-INF/classes/T1.class, comment=T1
entry=BOOT-INF/classes/T2.class, comment=T2
entry=BOOT-INF/classes/T3.class, comment=T3
entry=BOOT-INF/classes/T4.class, comment=T4
entry=T0.class, comment=�1
entry=T1.class, comment=�1
entry=T2.class, comment=�1
entry=T3.class, comment=�1
entry=T4.class, comment=�1
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 17, 2024
@philwebb philwebb self-assigned this Jan 17, 2024
@philwebb philwebb changed the title JarEntry#getComment() get different value when use JarFile and NestedJarFile ? JarEntry.getComment() returns incorrect result from NestedJarFile instances Jan 17, 2024
@philwebb philwebb added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 17, 2024
@philwebb philwebb added this to the 3.2.2 milestone Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants