Plexus Utils
  1. Plexus Utils
  2. PLXUTILS-9

PlexusUtils.getSystemEnvVars doesn't clean up resources

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Using the embedder I am hitting the following issue;

      java 7399 jerome 7u sock 0,4 25306792 can't identify protocol
      java 7399 jerome 8u IPv6 25306796 TCP *:8181 (LISTEN)
      java 7399 jerome 9r REG 3,66 90 34656 /home/jerome/.mailcap
      java 7399 jerome 10w FIFO 0,5 25416706 pipe
      java 7399 jerome 11w FIFO 0,5 25436577 pipe
      java 7399 jerome 12w FIFO 0,5 25320121 pipe
      java 7399 jerome 13r FIFO 0,5 25320122 pipe
      java 7399 jerome 14w FIFO 0,5 25328530 pipe
      java 7399 jerome 15r FIFO 0,5 25320123 pipe
      java 7399 jerome 16w FIFO 0,5 25315686 pipe
      java 7399 jerome 17r FIFO 0,5 25315687 pipe
      java 7399 jerome 18w FIFO 0,5 25320126 pipe
      java 7399 jerome 19r FIFO 0,5 25315688 pipe
      java 7399 jerome 20r FIFO 0,5 25320127 pipe
      java 7399 jerome 21r FIFO 0,5 25328531 pipe
      java 7399 jerome 22r FIFO 0,5 25320128 pipe

      [...]

      java 7399 jerome 1007r FIFO 0,5 26391458 pipe
      java 7399 jerome 1008r FIFO 0,5 26416550 pipe
      java 7399 jerome 1009w FIFO 0,5 26421728 pipe
      java 7399 jerome 1010r FIFO 0,5 26416551 pipe
      java 7399 jerome 1011r FIFO 0,5 26421729 pipe
      java 7399 jerome 1012w FIFO 0,5 26421776 pipe
      java 7399 jerome 1013r FIFO 0,5 26421730 pipe
      java 7399 jerome 1014r FIFO 0,5 26421777 pipe
      java 7399 jerome 1015w FIFO 0,5 26425995 pipe
      java 7399 jerome 1016r FIFO 0,5 26421778 pipe
      java 7399 jerome 1017r FIFO 0,5 26425996 pipe
      java 7399 jerome 1019r FIFO 0,5 26425997 pipe
      java 7399 jerome 1020r FIFO 0,5 26434244 pipe

      Exception in thread "Thread-1796" java.io.IOException: java.io.IOException: Too many open files
      at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
      at java.lang.ProcessImpl.start(ProcessImpl.java:65)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
      at java.lang.Runtime.exec(Runtime.java:591)
      at java.lang.Runtime.exec(Runtime.java:429)
      at java.lang.Runtime.exec(Runtime.java:326)
      at org.codehaus.plexus.util.cli.CommandLineUtils.getSystemEnvVars(CommandLineUtils.java:177)
      at org.apache.maven.project.interpolation.RegexBasedModelInterpolator.<init>(RegexBasedModelInterpolator.java:60)
      at sun.reflect.GeneratedConstructorAccessor56.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at java.lang.Class.newInstance0(Class.java:350)
      at java.lang.Class.newInstance(Class.java:303)
      at org.codehaus.plexus.component.factory.java.JavaComponentFactory.newInstance(JavaComponentFactory.java:44)
      at org.codehaus.plexus.DefaultPlexusContainer.createComponentInstance(DefaultPlexusContainer.java:1464)
      at org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:93)
      at org.codehaus.plexus.component.manager.ClassicSingletonComponentManager.getComponent(ClassicSingletonComponentManager.java:92)
      at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:331)
      at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:129)
      at org.codehaus.plexus.component.composition.FieldComponentComposer.assembleComponent(FieldComponentComposer.java:73)
      at org.codehaus.plexus.component.composition.DefaultComponentComposerManager.assembleComponent(DefaultComponentComposerManager.java:68)
      at org.codehaus.plexus.DefaultPlexusContainer.composeComponent(DefaultPlexusContainer.java:1486)
      at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:29)
      at org.codehaus.plexus.lifecycle.AbstractLifecycleHandler.start(AbstractLifecycleHandler.java:101)
      at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:105) at org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:95)
      at org.codehaus.plexus.component.manager.ClassicSingletonComponentManager.getComponent(ClassicSingletonComponentManager.java:92)
      at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:331)
      at org.codehaus.plexus.embed.Embedder.lookup(Embedder.java:78)
      at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:610)
      [...]

      The aforementionned method doesn't clean up the Process resources. Blocker as it makes it impossible to reuse the embedder.

        Activity

        Hide
        Jerome Lacoste added a comment -

        I wasn't able to reproduce it yet. I've used the following code snippet from kenney

        import java.io.*;

        public class TestIt
        {
        public static void main(String argv[])
        throws java.io.IOException, InterruptedException
        {
        for ( int i = 0; ; i++)
        {
        if ( i % 10 == 0 )
        System.out.println( i );
        // Thread.sleep(50);
        /* new Thread(new Runnable() {
        public void run() {
        try

        { */ test(); /* }

        catch (Exception e)

        { e.printStackTrace(); }

        }
        }).start();
        */
        }
        }

        private static void test()
        throws java.io.IOException
        {
        Process p = Runtime.getRuntime().exec("env | cat");
        BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
        while (br.readLine() != null ) {}

        }
        }

        It ran up to 40k without issues. I tried adding threads but that didn't trigger it. I monitored the number of open descriptors and it went between 1 and 650. My limit is 1024.

        Doing:

        ulimit -n 500 && java TestIt reproduced the issue easily but that's kind of cheating

        Maybe another part of the system generates these pipes and they are uncovered by this call? I will close the issue until I find the real culprit...

        For reference: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692

        Show
        Jerome Lacoste added a comment - I wasn't able to reproduce it yet. I've used the following code snippet from kenney import java.io.*; public class TestIt { public static void main(String argv[]) throws java.io.IOException, InterruptedException { for ( int i = 0; ; i++) { if ( i % 10 == 0 ) System.out.println( i ); // Thread.sleep(50); /* new Thread(new Runnable() { public void run() { try { */ test(); /* } catch (Exception e) { e.printStackTrace(); } } }).start(); */ } } private static void test() throws java.io.IOException { Process p = Runtime.getRuntime().exec("env | cat"); BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); while (br.readLine() != null ) {} } } It ran up to 40k without issues. I tried adding threads but that didn't trigger it. I monitored the number of open descriptors and it went between 1 and 650. My limit is 1024. Doing: ulimit -n 500 && java TestIt reproduced the issue easily but that's kind of cheating Maybe another part of the system generates these pipes and they are uncovered by this call? I will close the issue until I find the real culprit... For reference: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692

          People

          • Assignee:
            Unassigned
            Reporter:
            Jerome Lacoste
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: