Skip to content

Commit

Permalink
fix(): getCorsMeta can be null
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawven committed Apr 11, 2024
1 parent e64fad4 commit 342c64f
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public void register(Invoker<?> invoker) {
continue;
}
RequestMapping classMapping = resolver.resolve(serviceMeta);
if (classMapping != null) {
classMapping.setCorsMeta(classMapping.getCorsMeta().combine(getGlobalCorsMeta()));
}
mergeGlobalCorsMeta(classMapping);
consumer.accept((methods) -> {
MethodMeta methodMeta = new MethodMeta(methods, serviceMeta);
RequestMapping methodMapping = resolver.resolve(methodMeta);
Expand Down Expand Up @@ -133,6 +131,17 @@ private HandlerMeta buildHandlerMeta(Invoker<?> invoker, MethodMeta methodMeta)
serviceDescriptor);
}

private void mergeGlobalCorsMeta(RequestMapping mapping) {
if (mapping != null) {
CorsMeta corsMeta = mapping.getCorsMeta();
if (corsMeta != null) {
mapping.setCorsMeta(corsMeta.combine(getGlobalCorsMeta()));
} else {
mapping.setCorsMeta(getGlobalCorsMeta());
}
}
}

@Override
public void unregister(Invoker<?> invoker) {
lock.writeLock().lock();
Expand Down

0 comments on commit 342c64f

Please sign in to comment.