SEZ9 opened a new pull request, #11983:
URL: https://github.com/apache/seatunnel/pull/11983

   ### Purpose of this pull request
   
   First item of #11981: the runtime log level endpoint reports `SUCCESS` for a 
level it never applied.
   
   `Log4j2HttpPostCommandProcessor#setLoggerLevel` passed the requested level 
name straight into
   `Configurator.setLevel(logger, Level.getLevel(level))`. 
`Level.getLevel(...)` returns `null` for an
   unregistered name instead of throwing, and log4j2 ignores a `null` level, so 
the handler answered
   `{"status":"SUCCESS"}` while the logger was left untouched. Because the 
level name is also
   case-sensitive, `debug` silently did nothing too.
   
   This PR resolves the level *before* applying it:
   
   - unknown level name → `400` with the list of valid level names;
   - blank logger name → `400`;
   - `{"status":"SUCCESS"}` only once a level was really applied;
   - level names are accepted in any letter case (`debug`, `Debug`, ` DEBUG ` 
all apply `DEBUG`).
   
   Parsing/applying moved into a small `LogLevels` helper, which the `/loggers` 
endpoints on the v2 REST
   plane (items b–d of #11981) will reuse in a follow-up PR. No behaviour is 
removed and no other
   endpoint changes.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, for `POST /hazelcast/rest/maps/log-level` on the legacy Hazelcast REST 
plane (unreleased-branch
   behaviour is being corrected; the endpoint is currently undocumented, 
documentation is part of the
   follow-up PR that adds the v2 `/loggers` endpoints).
   
   Before:
   
   ```
   $ curl -X POST -d 'user&pass&org.apache.seatunnel&DEBUGG' 
http://127.0.0.1:5801/hazelcast/rest/maps/log-level
   {"status":"SUCCESS"}      # HTTP 200 — but the level was never changed
   
   $ curl -X POST -d 'user&pass&org.apache.seatunnel&debug' 
http://127.0.0.1:5801/hazelcast/rest/maps/log-level
   {"status":"SUCCESS"}      # HTTP 200 — also a no-op, the name is 
case-sensitive
   ```
   
   After:
   
   ```
   $ curl -X POST -d 'user&pass&org.apache.seatunnel&DEBUGG' 
http://127.0.0.1:5801/hazelcast/rest/maps/log-level
   Unknown logger level 'DEBUGG', valid levels are: OFF, FATAL, ERROR, WARN, 
INFO, DEBUG, TRACE, ALL
                             # HTTP 400
   
   $ curl -X POST -d 'user&pass&org.apache.seatunnel&debug' 
http://127.0.0.1:5801/hazelcast/rest/maps/log-level
   {"status":"SUCCESS"}      # HTTP 200 — DEBUG is applied
   ```
   
   A caller that was sending a valid, correctly-cased level keeps seeing 
exactly the same response.
   
   ### How was this patch tested?
   
   New unit test `LogLevelsTest` in `seatunnel-engine-server`:
   
   - valid names are parsed case-insensitively and with surrounding whitespace 
(`DEBUG`, `debug`,
     `Debug`, `" DEBUG "`, `"\tdebug\n"`);
   - unknown names (`DEBUGG`, `verbose`, `1`, `INFO,DEBUG`), blank names and 
`null` all resolve to
     `null`, i.e. they can no longer reach `Configurator`;
   - `validNames()` lists every level registered in log4j2;
   - `apply()` really changes the effective level of a logger (asserted through
     `LogManager.getLogger(...).getLevel()`, restored afterwards).
   
   ### Check list
   
   * [x] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
 — no new dependency.
   * [x] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs — the
     endpoint is undocumented today; documentation comes with the v2 `/loggers` 
endpoints in the follow-up PR for #11981.
   * [x] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR — not
     added: the only callers affected are those that were sending a level that 
had no effect anyway. Happy to add an entry if reviewers prefer.
   * [x] If you are contributing the connector code, please check that the 
following files are updated — not a connector change.
   


-- 
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