Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 07bab57

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Add a little type safety to DaemonicParserState
Summary: Otherwise it's too easy to obtain a cache for different type and get a runtime error (which I had during developement of another diff). Reviewed By: styurin shipit-source-id: d2a07b5bb7
1 parent 3bffb05 commit 07bab57

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/com/facebook/buck/parser/DaemonicParserState.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ LoadingCache<Cell, BuildFileTree> getBuildFileTrees() {
382382
* types with generics. Care should be taken to ensure that the correct class object is passed in.
383383
*/
384384
@SuppressWarnings("unchecked")
385-
public <T> PipelineNodeCache.Cache<BuildTarget, T> getOrCreateNodeCache(Class<?> cacheType) {
385+
public <T> PipelineNodeCache.Cache<BuildTarget, T> getOrCreateNodeCache(Class<T> cacheType) {
386386
try {
387387
return (PipelineNodeCache.Cache<BuildTarget, T>) typedNodeCaches.get(cacheType);
388388
} catch (ExecutionException e) {

src/com/facebook/buck/parser/PerBuildStateFactoryWithConfigurableAttributes.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.facebook.buck.core.cell.Cell;
2020
import com.facebook.buck.core.config.BuckConfig;
21+
import com.facebook.buck.core.model.BuildTarget;
2122
import com.facebook.buck.core.model.impl.MultiPlatformTargetConfigurationTransformer;
2223
import com.facebook.buck.core.model.targetgraph.TargetNode;
2324
import com.facebook.buck.core.model.targetgraph.impl.TargetNodeFactory;
@@ -200,9 +201,14 @@ protected PerBuildState create(
200201
MoreExecutors.listeningDecorator(
201202
createExecutorService(rootCell.getBuckConfig(), "configured-pipeline"));
202203

204+
@SuppressWarnings("unchecked")
205+
PipelineNodeCache.Cache<BuildTarget, TargetNode<?>> nodeCache =
206+
daemonicParserState.getOrCreateNodeCache(
207+
(Class<TargetNode<?>>) (Class<?>) TargetNode.class);
208+
203209
ParsePipeline<TargetNode<?>> targetNodeParsePipeline =
204210
new RawTargetNodeToTargetNodeParsePipeline(
205-
daemonicParserState.getOrCreateNodeCache(TargetNode.class),
211+
nodeCache,
206212
configuredPipelineExecutor,
207213
rawTargetNodePipeline,
208214
eventBus,

0 commit comments

Comments
 (0)