GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [core] Disable Caching in URLConnection for ClasspathClassLoader by adangel · Pull Request #4949 · pmd/pmd

Conversation

@adangel

@adangel adangel commented Apr 11, 2024

Copy link
Copy Markdown
Member

Describe the PR

That's the easiest solution I came up with - just disabling the cache for Jar Files.
I'm not sure about the memory/performance consequences. In case this is bad, we probably need to write our own "URLClassLoader" that caches Jarfiles not globally but only within our ClasspathClassLoader instance.

Related issues

  • Fixes [java] Parsing failed in ParseLock#doParse() java.io.IOException: Stream closed #4899

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
adangel added 2 commits April 11, 2024 14:52
@adangel
[core] Disable Caching in URLConnection for ClasspathClassLoader
62f2159
Fixes pmd#4899
@adangel
Add @mkolesnikov as a contributor
a65975b
@adangel adangel added the a:bug PMD crashes or fails to analyse a file. label Apr 11, 2024
@adangel adangel added this to the 7.1.0 milestone Apr 11, 2024
@adangel
Merge branch 'master' into issue-4899-jar-closed
db04a2c
@ghost

ghost commented Apr 11, 2024

Copy link
Copy Markdown
1 Message
📖 Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Apr 11, 2024
[maven] Classloader not being closed after PMD run #2163
Closed
[doc] Improve doc around PMDConfiguration#prependAuxclasspath #setClassloader #4952
Closed
[core] Deprecate PMDConfiguration#setClassloader and #getClassloader #4953
Closed
jsotuyod
jsotuyod reviewed Apr 11, 2024
View reviewed changes
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java
// Uses a pseudo URL to be able to call URLConnection#setDefaultUseCaches
// with Java9+ there is a static method for that per protocol:
// https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/URLConnection.html#setDefaultUseCaches(java.lang.String,boolean)
URI.create("jar:file:file.jar!/").toURL().openConnection().setDefaultUseCaches(false);

@jsotuyod jsotuyod Apr 11, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it a little disturbing that there is very little documentation as to what openConnection() does or when it may throw an IOException. For HTTP/HTTPS it's explicitly stated that no connection is open until connect() is invoked, but for files I've found nothing at all…

We are effectively relying on openConnection() not checking or touching the file for this to work…

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jsotuyod
jsotuyod merged commit c472fdf into pmd:master Apr 11, 2024
@adangel
adangel deleted the issue-4899-jar-closed branch April 12, 2024 09:12
@zbynek zbynek mentioned this pull request Sep 22, 2025
[java] java.lang.OutOfMemoryError: Java heap space when accessing big Jar files with PMD 7 #6010
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jsotuyod jsotuyod jsotuyod left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

a:bug PMD crashes or fails to analyse a file.

Projects

None yet

Milestone

7.1.0

Development

Successfully merging this pull request may close these issues.

[java] Parsing failed in ParseLock#doParse() java.io.IOException: Stream closed

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@adangel @jsotuyod
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.