altoclef icon indicating copy to clipboard operation
altoclef copied to clipboard

Double Nested mutex (Minor)

Open TacoTechnica opened this issue 3 years ago • 0 comments

Make this more granular, and test thoroughly to make sure there are no multi-threaded shenanigans.

https://github.com/adrisj7-AltoClef/altoclef/blob/23bb175e0c85b5d5a7918fd9413ffe653f8f21df/src/main/java/adris/altoclef/ConfigState.java#L298

        private void readExtraState(AltoClefSettings settings) {
            synchronized (settings.getBreakMutex()) { // TODO: 2021-05-22 why is there synchronized nesting here?
                synchronized (settings.getPlaceMutex()) {
                    blocksToAvoidBreaking = new HashSet<>(settings.getBlocksToAvoidBreaking());
                    toAvoidBreaking = new ArrayList<>(settings.getBreakAvoiders());
                    toAvoidPlacing = new ArrayList<>(settings.getPlaceAvoiders());
                    protectedItems = new ArrayList<>(settings.getProtectedItems());
                    synchronized (settings.getPropertiesMutex()) {
                        allowWalking = new ArrayList<>(settings.getForceWalkOnPredicates());
                    }
                }
            }
            allowWalkThroughFlowingWater = settings.isFlowingWaterPassAllowed();
            allowShears = settings.areShearsAllowed();

            rayFluidHandling = RayTraceUtils.fluidHandling;
            mineProcSearchAnyFlag = MineProcess.searchAnyFlag;
        }

TacoTechnica avatar May 30 '21 16:05 TacoTechnica