Package hudson.plugins.perforce.utils

Examples of hudson.plugins.perforce.utils.TimedStreamCloser


      p4.exec(cmd);
      BufferedReader reader = p4.getReader();
      String line = null;
      totalLength = 0;
      lines = new ArrayList<String>(1024);
                        TimedStreamCloser timedStreamCloser=null;
      try
      {
                             PerforceSCM.PerforceSCMDescriptor scmDescr = PerforceSCM.getInstance();
                             p4.getWriter().close();
                             int timeout = -1;
                             if(scmDescr.hasP4ReadlineTimeout()) { // Implementation with timeout
                               timeout = scmDescr.getP4ReadLineTimeout();
                            
                             timedStreamCloser = new TimedStreamCloser(p4.getInputStream(), timeout);
                             timedStreamCloser.start();

                             while((line = reader.readLine()) != null) {
                                timedStreamCloser.reset();
                                // only check for errors if we have not found one already
                                if (mesgIndex == -1)
                                    mesgIndex = checkAuthnErrors(line);
                                if(filter.reject(line)) continue;
                                lines.add(line);
                                totalLength += line.length();
                                count++;
                            }
                            if(timedStreamCloser.timedOut()) {
                                throw new PerforceException("Perforce operation timed out after " + timeout + " seconds.");
                            }
      }
      catch(IOException ioe)
      {
        //this is generally not anything to worry about.  The underlying
        //perforce process terminated and that causes java to be angry
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw, true);
        ioe.printStackTrace(pw);
        pw.flush();
        sw.flush();
        getLogger().warn("Perforce process terminated suddenly");
        getLogger().warn(sw.toString());
      }
      finally{
                            if(timedStreamCloser!=null) timedStreamCloser.interrupt();
                            try{
                                p4.getWriter().close();
                            } catch (IOException e) {
                                getLogger().warn("Write pipe failed to close.");
                            }
View Full Code Here

TOP

Related Classes of hudson.plugins.perforce.utils.TimedStreamCloser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.