@@ -442,31 +442,16 @@ public byte[] generateBuildConfig() throws IOException {
442
442
}
443
443
return customBuildConfig != null
444
444
? customBuildConfig .getBytes (StandardCharsets .UTF_8 )
445
- : getProjectBuildConfig ();
446
- }
447
-
448
- /**
449
- * If a project build config exists, return this as a byte array, or null if not available.
450
- */
451
- private byte [] getProjectBuildConfig () {
452
- Project project = parentProject ();
453
- return project .buildConfig != null
454
- ? writeToBytes (project .buildConfig )
455
445
: null ;
456
446
}
457
447
458
448
public String generateBuildConfigAsString () {
459
- if (customBuildConfig != null ) return customBuildConfig ;
460
- return writeToString (this .parentProject ().buildConfig );
461
- }
462
-
463
- /** Convenience method to write serializable object (primarily for router/build config objects) to byte array. */
464
- private <O extends Serializable > byte [] writeToBytes (O object ) {
465
449
try {
466
- return otpConfigMapper .writer ().writeValueAsBytes (object );
467
- } catch (JsonProcessingException e ) {
468
- LOG .error ("Value contains malformed JSON" , e );
469
- return null ;
450
+ return new String (generateBuildConfig (), StandardCharsets .UTF_8 );
451
+ // TODO: Correctly generate default build config
452
+ } catch (Exception e ) {
453
+ LOG .error ("Failed to generate build config: " , e );
454
+ return "" ;
470
455
}
471
456
}
472
457
@@ -487,37 +472,17 @@ public byte[] generateRouterConfig() throws IOException {
487
472
customRouterConfig = downloadedConfig ;
488
473
}
489
474
490
- byte [] customRouterConfigString = customRouterConfig != null
475
+ return customRouterConfig != null
491
476
? customRouterConfig .getBytes (StandardCharsets .UTF_8 )
492
477
: null ;
493
-
494
- byte [] routerConfigString = parentProject ().routerConfig != null
495
- ? writeToBytes (parentProject ().routerConfig )
496
- : null ;
497
-
498
- // If both router configs are present, merge the JSON before returning
499
- // Merger code from: https://stackoverflow.com/questions/35747813/how-to-merge-two-json-strings-into-one-in-java
500
- if (customRouterConfigString != null && routerConfigString != null ) {
501
- ObjectMapper mapper = new ObjectMapper ();
502
- Map <String , Object > map1 = mapper .readValue (customRouterConfigString , Map .class );
503
- Map <String , Object > map2 = mapper .readValue (routerConfigString , Map .class );
504
- Map <String , Object > merged = new HashMap <String , Object >(map2 );
505
- merged .putAll (map1 );
506
- return mapper .writeValueAsString (merged ).getBytes ();
507
- }
508
-
509
- return customRouterConfigString != null
510
- ? customRouterConfigString
511
- : routerConfigString != null
512
- ? routerConfigString
513
- : null ;
514
478
}
515
479
516
480
/** Generate router config for deployment as byte array (for writing to file output stream). */
517
481
public String generateRouterConfigAsString () {
518
482
try {
519
483
return new String (generateRouterConfig (), StandardCharsets .UTF_8 );
520
- } catch (IOException e ) {
484
+ // TODO: Correctly generate default router config
485
+ } catch (Exception e ) {
521
486
LOG .error ("Failed to generate router config: " , e );
522
487
return "" ;
523
488
}
0 commit comments