phet commented on code in PR #3857:
URL: https://github.com/apache/gobblin/pull/3857#discussion_r1450815488


##########
gobblin-service/src/main/java/org/apache/gobblin/service/monitoring/DagActionStoreChangeMonitor.java:
##########
@@ -276,8 +277,12 @@ protected void 
submitFlowToDagManagerHelper(DagActionStore.DagAction dagAction,
     try {
       URI flowUri = FlowSpec.Utils.createFlowSpecUri(flowId);
       spec = (FlowSpec) flowCatalog.getSpecs(flowUri);

Review Comment:
   if you're wondering how Java knows which to choose at runtime - given this 
is still an `@Override`, per usual it's chosen dynamically based on the runtime 
type.
   
   the difference here is the more-specific typing in cases where the 
`SpecCatalog` derived type can be guaranteed statically.
   
   to illustrate, these two are legal:
   ```
   URI uri = ...
   SpecCatalog sc = ...
   Spec s = sc.getSpecs(uri);
   ```
   and
   ```
   FlowSpecCatalog fsc = ...
   FlowSpec fs = fsc.getSpecs(uri);
   ```
   but this does NOT type-check:
   ```
   SpecCatalog sc = ...
   FlowSpec fs = sc.getSpecs(uri);
   ```
   
   it not only saves us typing on casting, but, in situations where we've 
already successfully casted to `FlowSpecCatalog`, it precludes failure from 
subsequent `ClassCastException` to `FlowSpec`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to