@@ -187,18 +187,8 @@ public class Exec implements Module {
187187 ImmutableMap
188188 .of (
189189 "cached" , (name , n , tf , opts ) -> Executors .newCachedThreadPool (tf .get ()),
190- "fixed" , (name , n , tf , opts ) -> {
191- Optional <Integer > size = Optional .ofNullable (
192- opts .containsKey ("size" ) ? Integer .parseInt (opts .get ("size" ).toString ()) : null
193- );
194- return Executors .newFixedThreadPool (size .orElse (n ), tf .get ());
195- },
196- "scheduled" , (name , n , tf , opts ) -> {
197- Optional <Integer > size = Optional .ofNullable (
198- opts .containsKey ("size" ) ? Integer .parseInt (opts .get ("size" ).toString ()) : null
199- );
200- return Executors .newScheduledThreadPool (size .orElse (n ), tf .get ());
201- },
190+ "fixed" , (name , n , tf , opts ) -> Executors .newFixedThreadPool (n , tf .get ()),
191+ "scheduled" , (name , n , tf , opts ) -> Executors .newScheduledThreadPool (n , tf .get ()),
202192 "forkjoin" , (name , n , tf , opts ) -> {
203193 boolean asyncMode = Boolean .parseBoolean (opts .getOrDefault ("asyncMode" , "false" )
204194 .toString ());
@@ -363,6 +353,7 @@ private static List<Map<String, Object>> executors(final ConfigValue candidate,
363353 return result ;
364354 }
365355
356+ @ SuppressWarnings ("unchecked" )
366357 private static Map <String , Object > executor (final String name , final boolean daemon ,
367358 final int priority ,
368359 final int n ,
@@ -371,23 +362,38 @@ private static Map<String, Object> executor(final String name, final boolean dae
371362 options .put ("name" , name );
372363 options .put ("daemon" , daemon );
373364 options .put ("priority" , priority );
374- Iterable <String > spec = Splitter .on ("," ).trimResults ().omitEmptyStrings ()
375- .split (value .toString ());
376- for (String option : spec ) {
377- String [] opt = option .split ("=" );
378- String optname = opt [0 ].trim ();
379- Object optvalue ;
380- if (optname .equals ("daemon" )) {
381- optvalue = opt .length > 1 ? Boolean .parseBoolean (opt [1 ].trim ()) : daemon ;
382- } else if (optname .equals ("asyncMode" )) {
383- optvalue = opt .length > 1 ? Boolean .parseBoolean (opt [1 ].trim ()) : false ;
384- } else if (optname .equals ("priority" )) {
385- optvalue = opt .length > 1 ? Integer .parseInt (opt [1 ].trim ()) : priority ;
386- } else {
387- optvalue = opt .length > 1 ? Integer .parseInt (opt [1 ].trim ()) : n ;
388- options .put ("type" , optname );
365+ if (value instanceof Map ) {
366+ Map <String , Object > config = (Map <String , Object >) value ;
367+ String type = config .get ("type" ).toString ();
368+ options .put ("type" , type );
369+ options .put (type , config .containsKey ("size" ) ?
370+ Integer .parseInt (config .get ("size" ).toString ()) : n );
371+ options .put ("daemon" , config .containsKey ("daemon" ) ?
372+ Boolean .parseBoolean (config .get ("daemon" ).toString ()) : daemon );
373+ options .put ("asyncMode" , config .containsKey ("asyncMode" ) ?
374+ Boolean .parseBoolean (config .get ("asyncMode" ).toString ()) : false );
375+ options .put ("priority" , config .containsKey ("priority" ) ?
376+ Integer .parseInt (config .get ("priority" ).toString ()) : priority );
377+ } else {
378+ System .out .println ("Bere" );
379+ Iterable <String > spec = Splitter .on ("," ).trimResults ().omitEmptyStrings ()
380+ .split (value .toString ());
381+ for (String option : spec ) {
382+ String [] opt = option .split ("=" );
383+ String optname = opt [0 ].trim ();
384+ Object optvalue ;
385+ if (optname .equals ("daemon" )) {
386+ optvalue = opt .length > 1 ? Boolean .parseBoolean (opt [1 ].trim ()) : daemon ;
387+ } else if (optname .equals ("asyncMode" )) {
388+ optvalue = opt .length > 1 ? Boolean .parseBoolean (opt [1 ].trim ()) : false ;
389+ } else if (optname .equals ("priority" )) {
390+ optvalue = opt .length > 1 ? Integer .parseInt (opt [1 ].trim ()) : priority ;
391+ } else {
392+ optvalue = opt .length > 1 ? Integer .parseInt (opt [1 ].trim ()) : n ;
393+ options .put ("type" , optname );
394+ }
395+ options .put (optname , optvalue );
389396 }
390- options .put (optname , optvalue );
391397 }
392398 return options ;
393399 }
0 commit comments