Uploaded image for project: 'Maven Eclipse Plugin (RETIRED)'
  1. Maven Eclipse Plugin (RETIRED)
  2. MECLIPSE-427

.springBeans definition throws NullPointer if BaseDir does not exist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5, 2.5.1
    • 2.6
    • MyEclipse support
    • None

    Description

      This is related to the fix submitted for MECLIPSE-359
      We have an application with 40 eclipse projects in it. About half of them have spring beans and 1/2 don't. The top level pom describes how the eclipse plugin should function and includes the Spring configuration component for the myeclipse target. A null pointer is thrown when running eclipse:myeclipse when the base dir doesn't exist, in our case in one of the projects that doesn't have any spring components. Our pom.xml fragment looks like

      <spring>
      <version>2.0</version>
      <file-pattern>*.xml</file-pattern>
      <basedir>src/main/resources/conf</basedir>
      </spring>

      The exception stack trace looks like

      java.lang.NullPointerException
      at org.apache.maven.plugin.eclipse.writers.myeclipse.MyEclipseSpringBeansWriter.getConfigurationFilesList(MyEclipseSpringBeansWriter.java:142)
      at org.apache.maven.plugin.eclipse.writers.myeclipse.MyEclipseSpringBeansWriter.write(MyEclipseSpringBeansWriter.java:93)

      The following code block with the problem throws NullPointer when directory.listFiles() returns a null into subdirs. Wrap the for() loop in a nullcheck

      try
      {
      File directory = new File( basedir );

      File[] subdirs = directory.listFiles( new FileFilter()
      {
      public boolean accept( File pathname )

      { return pathname.isDirectory(); }

      } );

      for ( int i = 0; i < subdirs.length; i++ )

      { configFiles.addAll( getConfigurationFilesList( subdirs[i].getPath(), pattern ) ); }

      configFiles.addAll( FileUtils.getFileNames( directory, pattern, null, true ) );
      }

      Testing:

      Take one of the test cases and remove the directory that is pointed to by the basedir attribute.

      Attachments

        1. testcase-project-meclipse-MECLIPSE-427.zip
          11 kB
          Joe Freeman
        2. MECLIPSE-427.patch
          9 kB
          Joe Freeman

        Activity

          People

            aheritier Arnaud Heritier
            clay_shooter Joe Freeman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: