Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-9178

ClassPathLoaderTest > testZeroLengthFile intermittently fails and touches filesystem

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: tests
    • Labels:
      None

      Description

      PR failure: https://concourse.apachegeode-ci.info/builds/27301

      > Task :geode-core:test
      
      org.apache.geode.internal.classloader.ClassPathLoaderTest > testZeroLengthFile FAILED
          java.lang.AssertionError: 
          Expecting actual throwable to be an instance of:
            java.lang.IllegalArgumentException
          but was:
            java.lang.NullPointerException
          	at java.io.File.<init>(File.java:365)
          	at org.apache.geode.deployment.internal.JarDeployer.getNextVersionedJarFile(JarDeployer.java:101)
          	at org.apache.geode.deployment.internal.JarDeployer.deployWithoutRegistering(JarDeployer.java:84)
          	...(59 remaining lines not displayed - this can be changed with Assertions.setMaxStackTraceElementsDisplayed)
              at org.apache.geode.internal.classloader.ClassPathLoaderTest.testZeroLengthFile(ClassPathLoaderTest.java:109)
      

      ClassPathLoaderTest also uses TemporaryFolder and uses the filesystem which does not belong in a "Unit Test":

        @Test
        public void testZeroLengthFile() throws IOException {
          File zeroFile = tempFolder.newFile("JarDeployerDUnitZLF.jar");
          zeroFile.createNewFile();
      
          JarDeploymentService jarDeploymentService =
              JarDeploymentServiceFactory.getJarDeploymentServiceInstance();
          assertThatThrownBy(() -> {
            Deployment deployment =
                new Deployment("JarDeployerDUnitZLF.jar", "test", Instant.now().toString());
            deployment.setFile(zeroFile);
            jarDeploymentService.deploy(
                deployment);
          }).isInstanceOf(IllegalArgumentException.class);
      
          byte[] validBytes = new ClassBuilder().createJarFromName("JarDeployerDUnitZLF1");
          File validFile = tempFolder.newFile("JarDeployerDUnitZLF1.jar");
          IOUtils.copy(new ByteArrayInputStream(validBytes), new FileOutputStream(validFile));
      
          Set<File> files = new HashSet<>();
          files.add(validFile);
          files.add(zeroFile);
      
          assertThatThrownBy(() -> {
            for (File file : files) {
              Deployment deployment = new Deployment(file.getName(), "test", Instant.now().toString());
              deployment.setFile(file);
              jarDeploymentService.deploy(deployment);
            }
          }).isInstanceOf(IllegalArgumentException.class);
      
          // clean up the deployed files
          jarDeploymentService.listDeployed()
              .forEach(deployment -> jarDeploymentService
                  .undeployByDeploymentName(deployment.getDeploymentName()));
        }
      

        Attachments

          Activity

            People

            • Assignee:
              klund Kirk Lund
              Reporter:
              klund Kirk Lund
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: