weibo1995 opened a new pull request, #172:
URL: https://github.com/apache/maven-resolver/pull/172

   Fix the problem that the dependency tree is different when DF and BF 
strategies are adopted when a dependency package has no children dependency.
   When BF is adopted, when a dependent package has no children dependency, it 
will not continue to call the doRecurse() method, that is, it will not call the 
CacheManager.cachewinner() to put this dependency package into the winnerGAs 
object, which affects the analysis results of dependency packages of the same 
GA. The current fix is to call the CacheManager.cachewinner() method when a 
dependent package has no children dependency, so that the dependent package can 
be found in winnerGAs.
   
   
   
   We take the dependency in the following figure as an example to illustrate 
the generation process of the problem.
   
![image](https://user-images.githubusercontent.com/104960983/166883126-fad4a7cf-956e-4b89-9879-487fce2faf5f.png)
   
   At org eclipse. aether. internal. impl. Bfdependencycollector 
#collectdependencies() mainly has two stages: processdependency() and 
transformer.transformGraph( node, context )。
   In the first stage of process dependency:
   1. When parsing to D1, descriptorResult.getDependencies().isEmpty(), so 
doRecurse() will not be executed Therefore, args.skipper.cache() will not be 
executed. The D1 will not exist in winnerGAs in the end.
   2. When parsing D2 of the same layer, because there is no same GA in 
winnerGAs, D2 and its children dependencies ( G1 and H1) will be parsed.
   3. When resolving to G2 on the same layer as G1, because winnerGAs already 
has G1, the resolution of the children dependencies of G2 will be skipped, that 
is, H2 will not be resolved.
   Then, to the second stage, transformgraph:
   4. Because D1 has the same depth as D2, D1 wins, that is, D2 and its 
children are eliminated, including G1
   5. Because G1 was eliminated, G2 won.
   
   Finally, the final dependency tree obtained by BF strategy is as follows:
   
![image](https://user-images.githubusercontent.com/104960983/166883171-998a8891-01d3-4988-bf09-1c4e91e08a1b.png)
   But the dependency tree obtained by DF is as follows:
   
![image](https://user-images.githubusercontent.com/104960983/166883198-1988a846-e94f-45e1-ad6a-61d2d0feeb4a.png)
   
   That is, in the final generated dependency tree, BF has less children 
dependency of G2 than DF.
   
   
   
   
   Signed-off-by: hongbo.weihb <hongbo.we...@alibaba-inc.com>


-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to