diff --git a/external-providers/java-external-provider/pkg/java_external_provider/provider.go b/external-providers/java-external-provider/pkg/java_external_provider/provider.go index 5d7afe33..f37880d3 100644 --- a/external-providers/java-external-provider/pkg/java_external_provider/provider.go +++ b/external-providers/java-external-provider/pkg/java_external_provider/provider.go @@ -46,7 +46,7 @@ const ( // Rule Location to location that the bundle understands var locationToCode = map[string]int{ //Type is the default. - "": 10, + "": 0, "inheritance": 1, "method_call": 2, "constructor_call": 3, diff --git a/jsonrpc2/jsonrpc2.go b/jsonrpc2/jsonrpc2.go index 23c6a86c..e23e773c 100644 --- a/jsonrpc2/jsonrpc2.go +++ b/jsonrpc2/jsonrpc2.go @@ -159,6 +159,9 @@ func (c *Conn) Call(ctx context.Context, method string, params, result interface } // is it an error response? if response.Error != nil { + if IsOOMError(response.Error) { + return fmt.Errorf("out of memory error, query is too broad or we need more resources") + } return response.Error } if result == nil || response.Result == nil { diff --git a/jsonrpc2/rpcerr.go b/jsonrpc2/rpcerr.go index 3514cb03..96df3245 100644 --- a/jsonrpc2/rpcerr.go +++ b/jsonrpc2/rpcerr.go @@ -1,13 +1,19 @@ package jsonrpc2 import ( + "fmt" "strings" ) var errFileClosed = "file already closed" var errBrokenPipe = "broken pipe" +var oomError = "java.lang.OutOfMemoryError" func IsRPCClosed(err error) bool { var errMsg = err.Error() return strings.HasSuffix(errMsg, errFileClosed) || strings.HasSuffix(errMsg, errBrokenPipe) } + +func IsOOMError(err *Error) bool { + return strings.Contains(fmt.Sprintf("%s", err.Data), oomError) +}