smolnar82 commented on a change in pull request #297: KNOX-2301 and KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396351060
##########
File path:
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
##########
@@ -571,13 +579,49 @@ private static File
resolveProviderConfigurationReference(final String reference
if (topologyFilename == null) {
topologyFilename = desc.getCluster();
}
+
topologyDescriptor = new File(destDirectory, topologyFilename +
".xml");
- try (OutputStream outputStream =
Files.newOutputStream(topologyDescriptor.toPath());
- OutputStreamWriter outputStreamWriter = new
OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
- BufferedWriter fw = new BufferedWriter(outputStreamWriter)) {
- fw.write(sw.toString());
- fw.flush();
+ // KNOX-2302
+ boolean persistGenerated = false;
+ // Determine if the topology already exists.
+ if (topologyDescriptor.exists()) {
+ // If it does, only overwrite it if it has changed (KNOX-2302)
+ // Compare the generated topology with the in-memory topology
+ Topology existing = null;
+ TopologyService topologyService =
gwServices.getService(ServiceType.TOPOLOGY_SERVICE);
+ for (Topology t : topologyService.getTopologies()) {
+ if (topologyFilename.equals(t.getName())) {
+ existing = t;
+ break;
+ }
Review comment:
Maybe introducing `topologyService.getTopology(String topologyName)`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services