The issue:
I have an industry that applies fleet listeners to all fleets in the system, tallies any FleetPoint loss, and adjusts output according to that.
It also creates a second market on the entity it is installed on, to enable production budget increase if Heavy Industry is present on the planet. The secondary market ("SalvageMarket") has an industry that gets the smallest produced amount of ship hulls on the primary market, and applies it to itself.
This SalvageMarket is created/removed depending on the presence of Heavy Industry.
All of the above works without a hitch.
The problem:
If HeavyIndustry is removed form a planet with an active SalvageMarket, the game crashes with a ConcurrentModificationError.
This is not caused by SalvageMarket removal directly - the game runs a few other methods from my class before crashing, even after SM is no longer present, and crashes once the removal triggers an economy update.
This does not happen in any other case - removing the ScrapYards is fine, up/downgrading...
Main Industry Class:
https://bitbucket.org/SirHartley/deconomics/src/master/deconomics_ScrapYardSecondary:
https://bitbucket.org/SirHartley/deconomics/src/master/deconomics_AltHullProdCrash info:
46435 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain - java.util.ConcurrentModificationException
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
at java.util.ArrayList$Itr.next(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomy.nextStep(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.nextStep(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.tripleStep(Unknown Source)
at com.fs.starfarer.campaign.ui.marketinfo.IndustryListPanel.recreateOverview(Unknown Source)
at com.fs.starfarer.campaign.ui.marketinfo.OO0o.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)