Skip to content

fix(metadata): publish time.Time as java.util.Date in service definition - #3806

Merged
AlexStocks merged 3 commits into
apache:developfrom
AsperforMias:fix-3803-time-field
Nov 12, 2026
Merged

AlexStocks merged 3 commits into
apache:developfrom
AsperforMias:fix-3803-time-field

Conversation

@AsperforMias

Copy link
Copy Markdown
Contributor

Description

Fixes #3803

Structs with a time.Time field could not be published to the ServiceDefinition, so the whole method was skipped and the service did not show up in Dubbo Admin.

This PR maps time.Time to java.util.Date, which is what the hessian2 and generic paths already use at runtime:

  • Service definition: time.Time is published as a java.util.Date leaf type, including pointers, slices and map values. Squashing a time.Time is still rejected.
  • Generic call arguments: a java.util.Date value can be passed as milliseconds, yyyy-MM-dd HH:mm:ss (both match PojoUtils.realize in Dubbo Java), or an RFC 3339 string (what Go and Admin emit as JSON). Values nested in structs, pointers, slices and maps are realized too. Fractional milliseconds and malformed strings return an error.
  • Generic call results: time.Time is returned as is at any depth and encoded as Date by hessian2, instead of being expanded into an empty map. The bean generalizer emits a primitive descriptor, matching JavaBeanSerializeUtil.

Verified end to end with Nacos 2.5.2, Dubbo Admin (develop) and the UserProvider sample from dubbo-go-samples: the service and its methods now appear in Admin with time shown as java.util.Date, and Admin debug invocation and the Go generic client both round-trip the time value in all three formats.

Checklist

  • I confirm the target branch is develop
  • I have run make fmt to format my code
  • I have run make test to run local tests
  • I have added tests that prove my fix is effective or that my feature works

…generic calls

Service definitions publish time.Time as the leaf java.util.Date instead of
skipping every method that reaches it.

Generic calls handle it the way Java PojoUtils/CompatibleTypeUtils handle Date:
- Realize accepts a Date (time.Time), epoch milliseconds, or a
  "yyyy-MM-dd HH:mm:ss" / RFC 3339 string, at any depth.
- The map generalizer returns time.Time unchanged at any depth, so hessian2
  writes a Date; it used to become an empty map outside direct struct fields.
- The bean generalizer writes it as a primitive java.util.Date descriptor.

Fixes apache#3803

Signed-off-by: AsperforMias <asperformias000@outlook.com>
Signed-off-by: AsperforMias <asperformias000@outlook.com>
Signed-off-by: AsperforMias <asperformias000@outlook.com>
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.75510% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.70%. Comparing base (60d1c2a) to head (1700529).
⚠️ Report is 1040 commits behind head on develop.

Files with missing lines Patch % Lines
filter/generic/generalizer/map.go 85.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #3806       +/-   ##
============================================
+ Coverage    46.76%   58.70%   +11.93%     
============================================
  Files          295      492      +197     
  Lines        17172    40432    +23260     
============================================
+ Hits          8031    23734    +15703     
- Misses        8287    14920     +6633     
- Partials       854     1778      +924     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlexStocks
AlexStocks requested a review from Alanxtl November 12, 2026 10:45
@AlexStocks
AlexStocks merged commit 07b3a56 into apache:develop Nov 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 结构体含 time.Time 字段时服务无法发布 ServiceDefinition,Admin 中看不到该服务

3 participants