apache / apache/shenyu

[BUG] ResourceServiceImpl.onPluginCreated performs multiple writes non-transactionally

Open Beginner friendly
#6,622 1 comment 0 reactions 0 assignees View on GitHub
admin priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: High
- files: `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ResourceServiceImpl.java:211-217`
- description: `onPluginCreated` (an `@EventListener(PluginCreatedEvent.class)`) calls `this.createOne(resourceDO)` (insert + `publisher.onCreated` which triggers `PermissionServiceImpl.onResourcesCreated` inserting a permission row) and then `insertResourceBatch(...)` (batch insert + batch permission insert). The method has no `@Transactional` annotation, unlike `onPluginDeleted` (line 224, which IS `@Transactional`). A failure mid-way leaves orphaned resource/permission rows.
- impact: Partial-failure leaves resources with missing data-permission resources, or permissions for resources that were not fully created.
- suggested_fix: Add `@Transactional(rollbackFor = Exception.class)` to `onPluginCreated`, mirroring `onPluginDeleted`.
- confidence: High
- related_existing: none.

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/00-consolidated-critical-high.md`](docs/scan2-2026-08-02/00-consolidated-critical-high.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ResourceServiceImpl.java:211-217 and compare onPluginCreated with the transactional onPluginDeleted at line 224. Trace createOne, insertResourceBatch, and the permission callbacks; done means a mid-operation failure cannot leave partial resource or permission rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, database
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.