apache / apache/grails-core

grails 4.0.3: Saving Domain Instance through Service doesn't check the version property

Open
#11,598 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

- [x] Steps to reproduce provided

### Steps to Reproduce

1. each new simple application with a Domain Class having a version property
2. call the same instance for edit in two browser tabs. Alternatively to one browser tab change the record's version field in an database editor
3. in first browser tab - change something and save it
4. in second browser tab - change something and save it

### Expected Behaviour

The update in the second browser tab should faiil with error flag on the "version" property (which was correctly incremented by the timely first update in the first tab)

### Actual Behaviour

The update in the second browser tab is succeeding, incrementing once more the version property and overwriting the changes in the first browser tab

The only workaround is to check myself params.version against a fresh fetched instance in the controller and rejectValue "version"

### Environment Information

- **Operating System**: Ubuntu 14.04
- **Grails Version:** 4.0.4 with dependencies from 4.0.3 (see Issue 11590)
- **JDK Version:**
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Please, can somebody check/confirm this issue? Thank you!

Contributor guide

Open the contributing guide

Research direction

Start with the service save path and the controller workaround described in the report, then reproduce the two-tab update against a simple domain class with a version property. Compare the service behavior with the expected version validation; done means the second update fails with an error on the version property instead of overwriting the first update.

Written by the indexing model from the issue text.

Assessment

Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.