Problem
Customer uploads an rpm to a hosted yum repo but the repomd.xml generated by NXRM ends up as zero bytes in size after it is rebuilt.
Reproduce Steps
This problem has only been noticed in a circumstance where NXRM process is being run under an IBM JVM - which is not actively tested and therefore unsupported by Sonatype.
1) Create a new yum hosted repo. The blobstore used is on local file system.
2) Upload rpm to hosted yum repo.
3) Wait 60 seconds for yum metadata to be built.
2019-12-12 11:05:40,999+0000 INFO [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoFacetImpl - Rebuilding yum metadata for repository test2
2019-12-12 11:05:41,001+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Calculating directories for generating Yum metadata for repository test2
2019-12-12 11:05:41,016+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Writing non-repomd metadata for repository test2 and directory
2019-12-12 11:05:41,023+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Adding RPM anaconda-19.31.123-1.el7.x86_64.rpm to metadata for repository test2 and directory
2019-12-12 11:05:41,029+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Building repomd.xml for repository test2 and directory
2019-12-12 11:05:41,031+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Reading metadata file ../sonatype-work/nexus3/tmp/filelists9182444827763335232xml.gz from directory to get checksums
2019-12-12 11:05:41,032+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Reading metadata file ../sonatype-work/nexus3/tmp/primary6716462931234905359xml.gz from directory to get checksums
2019-12-12 11:05:41,033+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Reading metadata file ../sonatype-work/nexus3/tmp/other725357052337904547xml.gz from directory to get checksums
2019-12-12 11:05:41,034+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Searching for comps.xml to add to metadata for directory
2019-12-12 11:05:41,043+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Removing temp files used in Yum metadata generation
2019-12-12 11:05:41,044+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Removing temporary Yum metadata file ../sonatype-work/nexus3/tmp/filelists9182444827763335232xml.gz
2019-12-12 11:05:41,044+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Removing temporary Yum metadata file ../sonatype-work/nexus3/tmp/primary6716462931234905359xml.gz
2019-12-12 11:05:41,045+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Removing temporary Yum metadata file ../sonatype-work/nexus3/tmp/other725357052337904547xml.gz
2019-12-12 11:05:41,045+0000 DEBUG [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoServiceImpl - Removing temporary Yum metadata file ../sonatype-work/nexus3/tmp/repomd7020056985363034710xml
2019-12-12 11:05:41,118+0000 INFO [event-6-thread-339] admin org.sonatype.nexus.repository.yum.internal.createrepo.CreateRepoFacetImpl - Finished rebuilding yum
4) Go to Browse tree on hosted yum repo and you will see the repomd.xml is zero bytes. All other yum metadata files have data in them.
5) Use curl to download the repomd.xml and it is zero bytes.
6) Examining the blobstore files for the repomd.xml
The 3f03d320-fa76-4f6d-8164-36b80065dae9.bytes is empty
The 3f03d320-fa76-4f6d-8164-36b80065dae9.properties shows that byte file is zero size.
#2019-12-12 11:05:41,095+0000
#Thu Dec 12 11:05:41 UTC 2019
@BlobStore.created-by=system
size=0
@Bucket.repo-name=test2
creationTime=1576148741095
@BlobStore.created-by-ip=system
@BlobStore.content-type=application/xml
@BlobStore.blob-name=repodata/repomd.xml
sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709
Diagnosis
We believe something specific to the IBM JVM or the application classpaths customer was using running NXRM contributed to the problem. When the customer reported they switched to OpenJDK JVM and a default nexus.vmoptions lauch file, the problem was not reproducible.
However, on investigating this issue, we did locate code in product that might leak streams used to write the repomd.xml file. Thus a change has been made to improve stream cleanup.