[ https://issues.apache.org/jira/browse/BEAM-7994?focusedWorklogId=297256&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-297256 ]
ASF GitHub Bot logged work on BEAM-7994: ---------------------------------------- Author: ASF GitHub Bot Created on: 19/Aug/19 16:18 Start Date: 19/Aug/19 16:18 Worklog Time Spent: 10m Work Description: wcn3 commented on pull request #9362: [BEAM-7994] Fixing unsafe pointer usage for Go 1.13 URL: https://github.com/apache/beam/pull/9362#discussion_r315296527 ########## File path: sdks/go/pkg/beam/core/util/reflectx/functions_test.go ########## @@ -0,0 +1,43 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package reflectx + +import ( + "reflect" + "testing" +) + +func testFunction() int { + return 42 +} + +func TestXxx(t *testing.T) { + val := reflect.ValueOf(testFunction) + fi := uintptr(val.Pointer()) + typ := val.Type() + + callable := LoadFunction(fi, typ) + + cv := reflect.ValueOf(callable) + out := cv.Call(nil) + if len(out) != 1 { + t.Errorf("got %d return values, wanted 1.", len(out)) + } + // TODO: check type? + if out[0].Int() != 42 { + t.Errorf("got %d, wanted 42", out[0].Int()) + } Review comment: I like this style, since the comma operator helps keep it compact. Joe made an offline comment that every usage of the unsafe package should be accompanied by a unit test. I agree with that, and I'm looking at the remaining unsafe usages in the SDK right now. I'll make this tweak in that followup PR. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 297256) Time Spent: 3h (was: 2h 50m) > BEAM SDK has compatibility problems with go1.13 > ----------------------------------------------- > > Key: BEAM-7994 > URL: https://issues.apache.org/jira/browse/BEAM-7994 > Project: Beam > Issue Type: Improvement > Components: sdk-go > Reporter: Bill Neubauer > Assignee: Bill Neubauer > Priority: Minor > Fix For: 2.16.0 > > Time Spent: 3h > Remaining Estimate: 0h > > The Go team identified a problem in the Beam SDK that appears due to runtime > changes in Go 1.13, which is upcoming. There is a backwards compatible fix > the team recommended. -- This message was sent by Atlassian Jira (v8.3.2#803003)