Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: unistack-org/micro
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.2.10
Choose a base ref
...
head repository: unistack-org/micro
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.2.11
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Feb 12, 2021

  1. metadata: fix nil metadata from FromIncoming/FromOutgoing context

    Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
    vtolstov committed Feb 12, 2021
    Copy the full SHA
    fd5ed64 View commit details
Showing with 6 additions and 5 deletions.
  1. +3 −3 metadata/context.go
  2. +3 −2 metadata/metadata_test.go
6 changes: 3 additions & 3 deletions metadata/context.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ func FromIncomingContext(ctx context.Context) (Metadata, bool) {
return nil, false
}
md, ok := ctx.Value(mdIncomingKey{}).(*rawMetadata)
if !ok {
if !ok || md.md == nil {
return nil, false
}
return md.md, ok
@@ -29,7 +29,7 @@ func FromOutgoingContext(ctx context.Context) (Metadata, bool) {
return nil, false
}
md, ok := ctx.Value(mdOutgoingKey{}).(*rawMetadata)
if !ok {
if !ok || md.md == nil {
return nil, false
}
return md.md, ok
@@ -44,7 +44,7 @@ func FromContext(ctx context.Context) (Metadata, bool) {
return nil, false
}
md, ok := ctx.Value(mdKey{}).(*rawMetadata)
if !ok {
if !ok || md.md == nil {
return nil, false
}
return md.md, ok
5 changes: 3 additions & 2 deletions metadata/metadata_test.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package metadata

import (
"context"
"fmt"
"testing"
)

@@ -25,7 +24,9 @@ func TestPassing(t *testing.T) {
if !ok {
t.Fatalf("missing metadata from outgoing context")
}
fmt.Printf("%#+v\n", md)
if v, ok := md.Get("Key1"); !ok || v != "Val1_new" {
t.Fatalf("invalid metadata value %#+v", md)
}
}

func TestMerge(t *testing.T) {