|
1 | 1 | /** |
2 | | - * (C) Copyright IBM Corporation 2019, 2026. |
| 2 | + * (C) Copyright IBM Corporation 2019, 2026 |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -2689,11 +2689,11 @@ private void toggleGenerateToSrc() { |
2689 | 2689 | } |
2690 | 2690 |
|
2691 | 2691 | private void deleteGenFeaturesFile(File dir) { |
2692 | | - // processConfigFileChange() ignores deletion of generated features file |
2693 | | - File srcGenFeaturesFile = new File(dir, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH); |
2694 | | - if (srcGenFeaturesFile.exists()) { |
2695 | | - if (!srcGenFeaturesFile.delete()) { |
2696 | | - debug("Error trying to delete the generated features file:" + srcGenFeaturesFile.getAbsolutePath()); |
| 2692 | + // N.B. processConfigFileChange() will be called upon deletion of generated features file, it should be ignored |
| 2693 | + File oldGenFeaturesFile = new File(dir, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH); |
| 2694 | + if (oldGenFeaturesFile.exists()) { |
| 2695 | + if (!oldGenFeaturesFile.delete()) { |
| 2696 | + debug("Error trying to delete the generated features file:" + oldGenFeaturesFile.getAbsolutePath()); |
2697 | 2697 | } |
2698 | 2698 | } |
2699 | 2699 | } |
@@ -4682,6 +4682,9 @@ private void processConfigFileChange(File fileChanged, ChangeType changeType, Th |
4682 | 4682 | // generateFeaturesTmpDir in the process of handling an xml config modicifcation. |
4683 | 4683 | // Deleting that directory could cause generated-features.xml to be deleted and we |
4684 | 4684 | // need to be careful how to handle that event e.g. don't call optimizeGenerateFeatures(). |
| 4685 | + // Another scenario, when we toggle generateToSrc option we delete the old file and change the |
| 4686 | + // value of generateFeaturesFile. Therefore we must only use the base name of generateFeaturesFile |
| 4687 | + // in this file name check. |
4685 | 4688 | if (generateFeatures && (fileChanged.getName().endsWith(".xml") |
4686 | 4689 | && !fileChanged.getName().equals(generateFeaturesFile.getName())) |
4687 | 4690 | && serverFeaturesModified()) { |
|
0 commit comments