Skip to content

Commit 8b0fee7

Browse files
committed
revel#756 defer close call for io.Closer
1 parent 369fe12 commit 8b0fee7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

invoker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package revel
22

33
import (
4+
"io"
45
"reflect"
56

67
"golang.org/x/net/websocket"
@@ -25,6 +26,11 @@ func ActionInvoker(c *Controller, _ []Filter) {
2526
boundArg = reflect.ValueOf(c.Request.Websocket)
2627
} else {
2728
boundArg = Bind(c.Params, arg.Name, arg.Type)
29+
// #756 - If the argument is a closer, defer a Close call,
30+
// so we don't risk on leaks.
31+
if closer, ok := boundArg.Interface().(io.Closer); ok {
32+
defer closer.Close()
33+
}
2834
}
2935
methodArgs = append(methodArgs, boundArg)
3036
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy