cfg4j / cfg4j

Modern configuration library for distributed apps written in Java.

Home Page:http://cfg4j.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lib is flooding root file system

kamurashev opened this issue · comments

The proj I'm working on is using the lib into automation test suits. Tests are being run by Jenkins and Jenkins being hosted on a bare metal. From time to time I'm facing with
IOException: No space left on device
It appears the lib is flooding /tmp directory with numerous of config file repo clones, e.g.:

jenkins@jenkinsmaster01:~$ ls -ld /tmp/cfg*
drwxr-xr-x 4 jenkins jenkins 4096 May 23 00:21 /tmp/cfg4j-git-config-repository1196432648052804977
drwxr-xr-x 3 jenkins jenkins 4096 May 19 17:36 /tmp/cfg4j-git-config-repository1210794336978573061
...
'a lot of same directories goes here'
...

Here's the place where the path being initialized:

tmpPath = Paths.get(System.getProperty("java.io.tmpdir"));

Each run new randomly named dir is created and NOT being cleared after:

clonedRepoPath = Files.createTempDirectory(tmpPath, tmpRepoPrefix);

I have a feeling this was intended to clear old copies, but in fact it doesn't as each time new random long is being appended to the path and old dirs is not deleted.

Given above:

  1. I believe it is must for documentation to mention that repo would be cloned to System temp directory and furthermore I believe the directory should be configurable, as a workaround I'm passing:
    -Djava.io.tmpdir={not-root/custom tmp dir} to java.
  2. Code should be updated so it would clear all the leftovers after its execution.

Ok, I digged a little more deeper in the code and now I can see there is a close method:


This should get the clean-up job done, but I just can't use it as it would require quite a substantial rewrite as when the code was initially written this aspect was missed by whomever was writing the code. Again it only tells us this aspect need to be documented so much. Hope this explanation of mine at least will help someone if they face with similar issue :-)