Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JMX nil pointer #307

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GO_VERSION = $(shell go version | sed 's/[^0-9.]*\([0-9.]*\).*/\1/')
GOTOOLS = github.com/axw/gocov/gocov \
github.com/AlekSi/gocov-xml

GOLANGCILINT_VERSION = v1.24.0
GOLANGCILINT_VERSION = v1.56.0
GOLANGCILINT_BIN = bin/golangci-lint

# Temporary patch to avoid build failing because of the outdated documentation example
Expand All @@ -24,7 +24,7 @@ bin:
.PHONY: tools/golangci-lint
tools/golangci-lint:
@echo "installing GolangCI lint"
@(wget -qO - https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s $(GOLANGCILINT_VERSION) )
@(wget -qO - https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCILINT_VERSION) )


.PHONY: tools
Expand Down
12 changes: 6 additions & 6 deletions args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func underscore(s string) string {
// fields it defines. Each of the fields in the struct can define their defaults
// and help string by using tags:
//
// type Arguments struct {
// DefaultArgumentList
// Argument1 bool `default:"false" help:"This is the help we will print"`
// Argument2 int `default:"1" help:"This is the help we will print"`
// Argument3 string `default:"value" help:"This is the help we will print"`
// }
// type Arguments struct {
// DefaultArgumentList
// Argument1 bool `default:"false" help:"This is the help we will print"`
// Argument2 int `default:"1" help:"This is the help we will print"`
// Argument3 string `default:"value" help:"This is the help we will print"`
// }
//
// The fields in the struct will be populated with the values set either from
// the command line or from environment variables.
Expand Down
1 change: 1 addition & 0 deletions docs/tutorial-code-v3/multiple-entities/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func queryAttrRedisInfo(query string, port int) (string, string) {
return strings.TrimSpace(splittedLine[0]), strings.TrimSpace(splittedLine[1])
}

// nolint: typecheck
func main() {
// Create Integration
i, err := integration.New(integrationName, integrationVersion, integration.Args(&args))
Expand Down
1 change: 1 addition & 0 deletions docs/tutorial-code-v3/single-entity/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func queryRedisConfig(query string) (string, string) {
return splittedLine[0], splittedLine[1]
}

// nolint: typecheck
func main() {
// Create Integration
i, err := integration.New(integrationName, integrationVersion, integration.Args(&args))
Expand Down
2 changes: 1 addition & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func Test_Integration_FindEntity(t *testing.T) {
assert.True(t, e.SameAs(e1))
}

//--- helpers
// --- helpers
func newTestIntegration(t *testing.T) *Integration {
i, err := New(integrationName, integrationVersion, Logger(log.Discard), Writer(ioutil.Discard))
assert.NoError(t, err)
Expand Down
9 changes: 6 additions & 3 deletions jmx/jmx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
Package jmx is a library to get metrics through JMX. It requires additional
setup. Read https://github.com/newrelic/infra-integrations-sdk#jmx-support for
instructions. */
instructions.
*/
package jmx

import (
Expand Down Expand Up @@ -236,8 +237,10 @@ func openConnection(config *connectionConfig) (err error) {
}

go func() {
if err = cmd.Wait(); err != nil {
cmdErrC <- jmxClientError(fmt.Sprintf("nrjmx error: %s [proc-state: %s]", err, cmd.ProcessState))
if cmd != nil {
if err = cmd.Wait(); err != nil {
cmdErrC <- jmxClientError(fmt.Sprintf("nrjmx error: %s [proc-state: %s]", err, cmd.ProcessState))
}
}

cmd = nil
Expand Down
1 change: 1 addition & 0 deletions jmx/jmx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestOpenURL(t *testing.T) {
assert.Equal(t, "sample.url", lastArg)
}

// nolint: goconst
func TestQuery(t *testing.T) {
for q, isErr := range query2IsErr {
require.NoError(t, openWait("", "", "", "", openAttempts), "error on opening for query %s", q)
Expand Down
4 changes: 3 additions & 1 deletion jmx/jmx_unix.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//go:build linux || darwin
// +build linux darwin

/*
Package jmx is a library to get metrics through JMX. It requires additional
setup. Read https://github.com/newrelic/infra-integrations-sdk#jmx-support for
instructions. */
instructions.
*/
package jmx

const (
Expand Down
Loading