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 — [java] CloseResource rule throws exception on spaces in property types · Issue #3089 · pmd/pmd

[java] CloseResource rule throws exception on spaces in property types #3089

New issue
Copy link
New issue
Copy link
Closed
#3143
Closed
[java] CloseResource rule throws exception on spaces in property types#3089
#3143
Copy link
Assignees
adangel
Labels
a:bugPMD crashes or fails to analyse a file.
Milestone
6.32.0

Description

@linusjf
linusjf
opened on Jan 31, 2021
Issue body actions

Affects PMD Version:
6.31.0

Worked in earlier versions.

Description:
Processing of rule CloseResource fails with PMDException when types property (which is a list of Java classes) has extraneous spaces between commas.

<rule ref="category/java/errorprone.xml/CloseResource">
    <properties>
      <property name="closeTargets" value="close"/>
      <property name="types" value="java.sql.Connection , java.sql.Statement , java.sql.ResultSet "/>
      <property name="closeAsDefaultTarget" value="true"/>
      <property name="allowedResourceTypes" value="java.io.ByteArrayOutputStream | java.io.ByteArrayInputStream | java.io.StringWriter | java.io.CharArrayWriter | java.util.stream.Stream | java.util.stream.IntStream | java.util.stream.LongStream | java.util.stream.DoubleStream"/>
      <property name="closeNotInFinally" value="true"/>
    </properties>
  </rule>
  

Exception Stacktrace:

/data/data/com.termux/files/home/DSAlgos/src/test/java/ds/tests/SinglyLinkedListTest.java: IllegalArgumentException: Not a Java binary name ' java.sql.Statement '  
java.lang.IllegalArgumentException: Not a Java binary name ' java.sql.Statement '       
  at net.sourceforge.pmd.internal.util.AssertionUtil.assertValidJavaBinaryName(AssertionUtil.java:33)                  
      at 
net.sourceforge.pmd.lang.java.types.TypeTestUtil.isA(TypeTestUtil.java:100)                                             at 
net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.isNodeInstanceOfResourceType(CloseResourceRule.java:352)                                         at 
net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.visit(CloseResourceRule.java:644)                  
     at 
net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix.jjtAccept(ASTPrimaryPrefix.java:48)                                  at 
net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:220)                                    at 
net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:607)                                    at 
net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression.jjtAccept(ASTPrimaryExpression.java:25)                      
    at 
net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:220)                                    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:337)                                    at net.sourceforge.pmd.lang.java.ast.ASTMemberValue.jjtAccept(ASTMemberValue.java:40)                                      at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:220)                                    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:322)                                    at net.sourceforge.pmd.lang.java.ast.ASTSingleMemberAnnotation.jjtAccept(ASTSingleMemberAnnotation.java:37)        
        at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:220)                                    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:307)                                    at net.sourceforge.pmd.lang.java.ast.ASTAnnotation.jjtAccept(ASTAnnotation.java:108)                                       at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:220)                                    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:417)                                    at net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration.jjtAccept(ASTTypeDeclaration.java:39)                        
      at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:220)                                    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visit(AbstractJavaRule.java:392)                                    at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.jjtAccept(ASTCompilationUnit.java:44)                           
   at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visitAll(AbstractJavaRule.java:163)                                 at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:157)                                    at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply(AbstractDelegateRule.java:336)                                 at net.sourceforge.pmd.RuleSet.apply(RuleSet.java:659)                         
   at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:163)                        
  at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:200)                                     at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:113)              
       at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:95)                             
     at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:57)                                 
 at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:85)          
  at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:29)          
  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)          
   at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)                                       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)            
 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)                               at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)                               at java.base/java.lang.Thread.run(Thread.java:834)                                                                

Steps to reproduce:

mvn -X pmd:pmd

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

Activity

  1. linusjf
    added
    a:bugPMD crashes or fails to analyse a file.
    on Jan 31, 2021
  2. oowekyala
    added this to the 6.32.0 milestone on Jan 31, 2021
  3. oowekyala commented on Jan 31, 2021

    @oowekyala
    oowekyala
    on Jan 31, 2021
    Member
    More actions

    Caused by #3064

  4. linusjf commented on Jan 31, 2021

    @linusjf
    linusjf
    on Jan 31, 2021
    Author
    More actions

    @oowekyala Evidently, something changed. IMO, there ought to be no whitespace, trailing or leading. Validating the properties is the best way to handle it. This should remain open until it's fixed in PMD 7.0.0. The workaround for now is to ensure no whitespace is present in properties.

  5. oowekyala commented on Feb 11, 2021

    @oowekyala
    oowekyala
    on Feb 11, 2021
    Member
    More actions

    This should remain open until it's fixed in PMD 7.0.0.

    Validating properties sure is a better long-term solution, let's add this to #1432 so that this ticket may be closed (since it's specific to CloseResource)

  6. linusjf commented on Feb 11, 2021

    @linusjf
    linusjf
    on Feb 11, 2021
    Author
    More actions

    This should remain open until it's fixed in PMD 7.0.0.

    Validating properties sure is a better long-term solution, let's add this to #1432 so that this ticket may be closed (since it's specific to CloseResource)

    As long as it's tracked in an open issue and then only fixed. There were a couple of instances of issues closed because they were to be fixed in PMD 7.0.0 only to have users re-open them. Hence, my response. You don't wish to have that happen once more.

  7. oowekyala commented on Feb 12, 2021

    @oowekyala
    oowekyala
    on Feb 12, 2021
    Member
    More actions

    Yes but here this is not the case, since I want to fix the regression for PMD 6.32

  8. adangel
    self-assigned this
    on Feb 26, 2021
  9. adangel
    added a commit that references this issue on Feb 26, 2021

    [core] Trim rule property values

    This issue will close once commit 27f007c is merged into the 'main' branch.
    27f007c
  10. adangel
    closed this as completedin #3143on Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @adangel
    adangel

Labels

a:bugPMD crashes or fails to analyse a file.

Type

No type

Projects

No projects

    Milestone

    • 6.32.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.