* test(sys): raise sys module line coverage to 99.59%
Adds 38 unit tests covering previously-untested branches in DiskUtils,
EnvUtil, InetUtils, PropertiesUtil, TimerContext, ModuleStateHolder, and
WatchFileCenter, lifting sys module line coverage from ~91.4% to 99.59%.
The 4 lines still uncovered are documented as unreachable or impractical
to cover: UTF-8 decoder trailing flush in DiskUtils, IBM-JDK fallback in
OperatingSystemBeanManager static init, and the WatchDirJob constructor
catch (would require swapping a static final FileSystem reference).
Assisted-by: Claude Code
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* style(sys): apply Spotless formatting to new coverage tests
Run mvn spotless:apply on sys module to fix the format violations
flagged by CI on the previous commit.
Assisted-by: Claude Code
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DiskUtils.readFile streams the file in 4096-byte chunks and feeds each
chunk to a CharsetDecoder. The current implementation has two related
correctness bugs that show up the moment a Nacos artifact contains
non-ASCII content:
1. The decoder is a process-wide `static final CharsetDecoder DECODER`.
`CharsetDecoder` is documented as not safe for concurrent use, and
it carries internal state across decode invocations. Sharing one
instance across every caller violates both invariants.
2. After draining the chars from each chunk the loop calls
`buffer.clear()`. When a multi-byte UTF-8 character straddles the
4096-byte boundary the decoder reports UNDERFLOW and leaves the
leading bytes of that character in the buffer; clear() then
discards them. The next read starts on an orphaned UTF-8
continuation byte, the decoder reports malformed input, and the
rest of the file is silently truncated.
Concretely, a file laid out as 4094 ASCII bytes + '中' (3-byte CJK,
E4 B8 AD) + 200 ASCII bytes round-trips back as just 4094 ASCII chars
with the trailing '中' and 200 ASCII bytes lost.
Fix both at the same time, since they are two halves of "stream UTF-8
correctly" inside the same loop:
- Allocate a fresh `CharsetDecoder` per call.
- Replace `buffer.clear()` with `buffer.compact()` so unconsumed
trailing bytes survive into the next read.
- After EOF, finalize the stream with `decoder.decode(buffer, ..., true)`
+ `decoder.flush(...)` so any tail bytes the decoder is still
holding are flushed into the output.
Tests in DiskUtilsTest:
- testReadFileWithMultiByteUtf8AcrossChunkBoundary builds the file
layout above, asserts the byte indices of '中' against the buffer
boundary, and asserts the exact round-trip. It fails
deterministically against the previous code (the trailing 200
bytes vanish) and passes after the fix.
- testReadFileWithSmallMultiByteUtf8Content covers the single-chunk
non-ASCII regression.
- testReadFileSequentialCallsAreIndependent guards the decoder-state
isolation that the per-call allocation buys.
This addresses the same anti-pattern as #15065 / #15073 in the sys
copy of DiskUtils. Multiple production callers (NacosCoreStartUp,
DerbySnapshotOperation, DistributedDatabaseOperateImpl,
PluginStateSnapshotOperation, AbstractServerStateHandler,
SwitchManager via readFileBytes, …) go through this readFile.
Assisted-by: Claude Code
- Update Makefile targets: simple -> microservice
- Rename FunctionMode.SIMPLE to FunctionMode.MICROSERVICE
- Update ConditionFunctionEnabled to use new mode name
- Adjust startup scripts and configuration references
- Code formatting improvements in filter classes
- Add FUNCTION_MODE_SIMPLE constant to support simple mode
- Update ConditionFunctionEnabled to enable both config and naming in simple mode
- Add unit tests for simple mode functionality
- Add Makefile with build and run targets for different function modes
- Update startup script and UI components to support simple mode
Simple mode enables both config and naming services simultaneously, providing
a convenient option for development and testing scenarios.
Add explicit StandardCharsets.UTF_8 to all DM_DEFAULT_ENCODING
occurrences reported by SpotBugs under threshold=High, and remove
the global exclusion from spotbugs-exclude.xml.
Affected modules: client-basic, client, common, config, core,
k8s-sync, naming, sys.
Signed-off-by: cxhello <caixiaohuichn@gmail.com>
* feat: grpc server startup support listen on specified ip
* feat: grpc server startup support listen on specified ip
* feat: grpc server startup support listen on specified ip
* feat: grpc server startup support listen on specified ip
* Feat support mcp registry api (#13376)
* Support tag fuzzy search (#13387)
* support tag fuzzy search
* support tag fuzzy search
* Merge pull request #13391 from luoxiner/support-mcp-multi-version
Feat Support Mcp Registry
* Add copyright for mcp-adapter pom.
* Support version in ai maintainer sdk and fix some errors when build (#13401)
* add version for ai maintainer sdk and support display mcp server config
* fix pmd errors
* fix empty endpoint
* remote publish api
* fix tag fuzzy search sql unit test (#13402)
* Fix unit test.
---------
Co-authored-by: Xin Luo <65529035+luoxiner@users.noreply.github.com>
Co-authored-by: Sunrisea <49605583+Sunrisea@users.noreply.github.com>
Co-authored-by: luoxin.luo <luoxin.luo@alibaba-inc.com>
* Fix cluster mode deployment can't change the server port problem.
* Fix cluster mode can't get service subscribers in console.
* Fix cluster mode can't get config listener in console.
* Support refresh nacos server member in console model.
* Mark old NamingMaintainService as deprecated.
* Use Import replace directly build Nacos Auth plugin bean in console.
* Using AutoConfiguration to inject nacos default auth plugin HTTP API.
* Use Page to replace List result for some maintainer api.
* Support namespace page.
* uniform Namespace model to api。
* Support console get server state from nacos-server
* Fix update namespace invalid problem.
* console support setting admin password.
* Add Console maintainer client auth plugin to support identity request.
* Support Nacos Console get users info from nacos server.
* Support Nacos Console get role and permission info from nacos server.
* Fix NPE by AuthConfig loading Circular Dependencies.
* Support start up with console only mode: step1 - basic start up.
* Support start up with console only mode: step2 - solve server state to fix console ui loading.
* Replace sync forward request with async request in DistroFilter. issue #10148
* extract method for config default headers
* add env switch for async distro forward.
* Fixed code review problems:
1. Move async forward switch from sys module to naming module.
2. use nacos code style to format code.
* Fixed nacos code checkstyle:
1. one import per Class
2. add javadoc
* In order to avoid additional overhead, move switch from GlobalConfig to ClientConfig and cache the env switch.
* Move switch from ClientConfig to DistroConfig.
* Removed unused import.
* Add test for async forward for DistroFilter
* Add license
* rename test method name
* Should enable async forward
* fixed test
* set async forward request switch to true in test
* fixed test: create and set property with MockEnvironment
* fixed check style
* move MockEnvironment init to BeforeClass
* add setter for asyncForwardRequest switch