File tree Expand file tree Collapse file tree 2 files changed +2
-43
lines changed Expand file tree Collapse file tree 2 files changed +2
-43
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ func (p *Patch) Unpatch() error {
113
113
}
114
114
115
115
func isPatchable (target , redirection * reflect.Value ) error {
116
+ patchLock .Lock ()
117
+ defer patchLock .Unlock ()
116
118
if target .Kind () != reflect .Func || redirection .Kind () != reflect .Func {
117
119
return errors .New ("the target and/or redirection is not a Func" )
118
120
}
Original file line number Diff line number Diff line change @@ -2,9 +2,7 @@ package mpatch
2
2
3
3
import (
4
4
"reflect"
5
- "runtime"
6
5
"testing"
7
- "time"
8
6
)
9
7
10
8
//go:noinline
@@ -136,44 +134,3 @@ func TestInstanceValuePatcher(t *testing.T) {
136
134
t .Fatal ("The unpatch did not work" )
137
135
}
138
136
}
139
-
140
- var slice []int
141
-
142
- //go:noinline
143
- func TestGarbageCollectorExperiment (t * testing.T ) {
144
-
145
- for i := 0 ; i < 10000000 ; i ++ {
146
- slice = append (slice , i )
147
- }
148
- go func () {
149
- var sl []int
150
- for i := 0 ; i < 10000000 ; i ++ {
151
- sl = append (slice , i )
152
- }
153
- _ = sl
154
- }()
155
- <- time .After (time .Second )
156
-
157
- aVal := methodA
158
- ptr01 := reflect .ValueOf (aVal ).Pointer ()
159
- slice = nil
160
- runtime .GC ()
161
- for i := 0 ; i < 10000000 ; i ++ {
162
- slice = append (slice , i )
163
- }
164
- go func () {
165
- var sl []int
166
- for i := 0 ; i < 10000000 ; i ++ {
167
- sl = append (slice , i )
168
- }
169
- _ = sl
170
- }()
171
- <- time .After (time .Second )
172
- slice = nil
173
- runtime .GC ()
174
- ptr02 := reflect .ValueOf (aVal ).Pointer ()
175
-
176
- if ptr01 != ptr02 {
177
- t .Fail ()
178
- }
179
- }
You can’t perform that action at this time.
0 commit comments