Aias00 opened a new issue, #6881:
URL: https://github.com/apache/shenyu/issues/6881

   ## Description
   `MockHandle.httpStatusCode` is declared as `private Integer httpStatusCode` 
with no default initializer (unlike `RedirectHandle` which defaults to 302). 
When a mock rule is saved without specifying `httpStatusCode`, Gson leaves the 
field null. `MockPlugin.doExecute` calls 
`HttpStatus.valueOf(mockHandle.getHttpStatusCode())` — 
`HttpStatus.valueOf(int)` receives a null `Integer`, auto-unboxing throws 
`NullPointerException`. Triggered on every request matching a mock rule whose 
handle JSON omits or nulls `httpStatusCode`.
   
   ## Location
   - 
`shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/MockPlugin.java:56`
   - 
`shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/MockHandle.java:27`
   
   ## Impact
   Every request to a mock route with a null status code returns 500 instead of 
the mock response.
   
   ## Suggested fix
   Default the field: `private Integer httpStatusCode = 200;` in `MockHandle`, 
or guard in `MockPlugin`: 
`HttpStatus.valueOf(Optional.ofNullable(mockHandle.getHttpStatusCode()).orElse(200))`.
   
   ## Related existing
   None — distinct from #6657 (GeneralContextPlugin NPE on null cached handle) 
which is about cache-miss null handle, not null field within a non-null handle.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to