From c700dc45d647b1c485ce3c90b04373d7ba7ea7bd Mon Sep 17 00:00:00 2001 From: David Christofas Date: Wed, 27 Apr 2022 14:52:54 +0200 Subject: [PATCH] implement workaround for chi.RegisterMethod --- changelog/unreleased/chi-method-workaround.md | 6 +++++ pkg/micro/ocdav/service.go | 22 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 changelog/unreleased/chi-method-workaround.md diff --git a/changelog/unreleased/chi-method-workaround.md b/changelog/unreleased/chi-method-workaround.md new file mode 100644 index 0000000000..7707545f0a --- /dev/null +++ b/changelog/unreleased/chi-method-workaround.md @@ -0,0 +1,6 @@ +Change: Implement workaround for chi.RegisterMethod + +Implemented a workaround for `chi.RegisterMethod` because of a concurrent map read write issue. +This needs to be fixed upstream in go-chi. + +https://github.com/cs3org/reva/pull/2785 diff --git a/pkg/micro/ocdav/service.go b/pkg/micro/ocdav/service.go index 9c002bf812..7b4f7652af 100644 --- a/pkg/micro/ocdav/service.go +++ b/pkg/micro/ocdav/service.go @@ -66,15 +66,17 @@ func Service(opts ...Option) (micro.Service, error) { return nil, err } + // Comment back in after resolving the issue in go-chi. + // See comment in line 87. // register additional webdav verbs - chi.RegisterMethod(ocdav.MethodPropfind) - chi.RegisterMethod(ocdav.MethodProppatch) - chi.RegisterMethod(ocdav.MethodLock) - chi.RegisterMethod(ocdav.MethodUnlock) - chi.RegisterMethod(ocdav.MethodCopy) - chi.RegisterMethod(ocdav.MethodMove) - chi.RegisterMethod(ocdav.MethodMkcol) - chi.RegisterMethod(ocdav.MethodReport) + // chi.RegisterMethod(ocdav.MethodPropfind) + // chi.RegisterMethod(ocdav.MethodProppatch) + // chi.RegisterMethod(ocdav.MethodLock) + // chi.RegisterMethod(ocdav.MethodUnlock) + // chi.RegisterMethod(ocdav.MethodCopy) + // chi.RegisterMethod(ocdav.MethodMove) + // chi.RegisterMethod(ocdav.MethodMkcol) + // chi.RegisterMethod(ocdav.MethodReport) r := chi.NewRouter() if err := useMiddlewares(r, &sopts, revaService); err != nil { @@ -82,6 +84,10 @@ func Service(opts ...Option) (micro.Service, error) { } r.Handle("/*", revaService.Handler()) + // This is a workaround for the go-chi concurrent map read write issue. + // After the issue has been solved upstream in go-chi we should switch + // back to using `chi.RegisterMethod`. + r.MethodNotAllowed(http.HandlerFunc(revaService.Handler().ServeHTTP)) hd := srv.NewHandler(r) if err := srv.Handle(hd); err != nil {