@@ -23,6 +23,7 @@ public final class Algorithm {
2323 private final HttpClient client ;
2424 private final Map <String , String > options ;
2525 private final AlgorithmOutputType outputType ;
26+ private static final long DEFAULT_TIMEOUT = 300L ;
2627 final static Gson gson = new Gson ();
2728
2829 public Algorithm (HttpClient client , AlgorithmRef algoRef ) {
@@ -54,12 +55,21 @@ public Algorithm setOption(String key, String value) {
5455 }
5556
5657 public Algorithm setTimeout (Long timeout , TimeUnit unit ) {
57- Long time = unit . convert (timeout , TimeUnit . SECONDS );
58+ Long time = TimeUnit . SECONDS . convert (timeout , unit );
5859 Map <String , String > optionsClone = new HashMap <String , String >(options );
5960 optionsClone .put (AlgorithmOptions .TIMEOUT .toString (), time .toString ());
6061 return new Algorithm (client , algoRef , optionsClone );
6162 }
6263
64+ public Long getTimeout () {
65+ String key = AlgorithmOptions .TIMEOUT .toString ();
66+ if (options .containsKey (key )) {
67+ return Long .parseLong (options .get (key ));
68+ }
69+ return DEFAULT_TIMEOUT ;
70+
71+ }
72+
6373 public Algorithm setStdout (boolean showStdout ) {
6474 Map <String , String > optionsClone = new HashMap <String , String >(options );
6575 optionsClone .put (AlgorithmOptions .STDOUT .toString (), Boolean .toString (showStdout ));
0 commit comments