Skip to content

Suggested fix for #1241#1274

Merged
LAGIdiot merged 1 commit intoGregTechCE:masterfrom
PrototypeTrousers:workbench-fix
Oct 26, 2020
Merged

Suggested fix for #1241#1274
LAGIdiot merged 1 commit intoGregTechCE:masterfrom
PrototypeTrousers:workbench-fix

Conversation

@PrototypeTrousers
Copy link
Copy Markdown
Contributor

@PrototypeTrousers PrototypeTrousers commented Oct 15, 2020

This PR solves the concurrent modification exception when using the crafting station with a recipe that has its ingredients split in adjacent inventories.

How solved: Changed use of hashMap to concurrentHashMap to avoid concurrent modification exception caused by iterating the hashMap.

consumeRecipeItems method in
gregtech/common/metatileentities/storage/CachedRecipeData.java
calls for the extractItem method in
gregtech/common/inventory/itemsource/NetworkItemInfo.java
that iterates the hashMap inventories on extractItem and recomputeItemAmount methods.

Outcome: Fixes: #1241

Possible compatibility issue: its said that concurrentHashMap is slower than hashMap, but the functions of the crafting station are all manual, so they shouldn't hurt much ?

Please fill in as much useful information as possible. Also please remove all unused sections.

@LAGIdiot
Copy link
Copy Markdown
Member

Please use proper template for creating PRs or I will decline this.

@PrototypeTrousers PrototypeTrousers changed the title Fixes #1241 Suggested fix for #1241 Oct 15, 2020
@LAGIdiot
Copy link
Copy Markdown
Member

Thank you for updating PR description. Fix of error seems sound and concerns regarding performance are not in place for this. Did you test by provided steps from issue?

@LAGIdiot LAGIdiot added the type: bug Something isn't working label Oct 16, 2020
@PrototypeTrousers
Copy link
Copy Markdown
Contributor Author

Yes, i tested using the steps on the issue report. after the changes theres no concurrent exception and the items are properly consumed even if they are split between inventories and there`s no duping

@LAGIdiot
Copy link
Copy Markdown
Member

Maybe I should extend PR template of section regarding testing...

Anyway I have tested and it works as expected. Accepted. Thanks for your hard work.

@LAGIdiot LAGIdiot merged commit 747091b into GregTechCE:master Oct 26, 2020
@PrototypeTrousers PrototypeTrousers deleted the workbench-fix branch May 25, 2021 14:03
Tictim referenced this pull request in Tictim/GregTech Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: accepted type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Crafting Station Crashes and dupes items when ingredients are split between inventories

2 participants