File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
src/org/opensolaris/opengrok/history Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 41
41
import java .util .List ;
42
42
import java .util .Locale ;
43
43
import java .util .TreeSet ;
44
+ import java .util .concurrent .TimeUnit ;
44
45
import java .util .logging .Level ;
45
46
import java .util .logging .Logger ;
46
47
import java .util .regex .Matcher ;
@@ -675,15 +676,27 @@ String determineCurrentVersion() throws IOException {
675
676
cmd .add ("-1" );
676
677
cmd .add ("--pretty=%cd: %h %an %s" );
677
678
cmd .add ("--date=format:%Y-%m-%d %H:%M" );
679
+
678
680
ProcessBuilder pb = new ProcessBuilder (cmd );
679
681
pb .directory (directory );
680
- Process process ;
681
- process = pb .start ();
682
+ Process process = pb .start ();
682
683
683
- try (BufferedReader in = new BufferedReader (new InputStreamReader (process .getInputStream ()))) {
684
- if ((line = in .readLine ()) != null ) {
685
- line = line .trim ();
684
+ try {
685
+ process .waitFor (15 , TimeUnit .SECONDS );
686
+
687
+ if (process .exitValue () != 0 ) {
688
+ throw new IOException ("Process exited with non zero exit code" );
689
+ }
690
+
691
+ try (BufferedReader in = new BufferedReader (new InputStreamReader (process .getInputStream ()))) {
692
+ if ((line = in .readLine ()) != null ) {
693
+ line = line .trim ();
694
+ }
686
695
}
696
+ } catch (InterruptedException ex ) {
697
+ LOGGER .log (Level .FINE , "Unable to determine current version for {} - process timeouted" , getDirectoryName ());
698
+ } catch (IOException ex ) {
699
+ LOGGER .log (Level .FINE , "Unable to determine current version for {} - bad exit code" , getDirectoryName ());
687
700
}
688
701
689
702
return line ;
You can’t perform that action at this time.
0 commit comments