diff --git a/sdks/java/container/boot.go b/sdks/java/container/boot.go index 3ce79e4927eb..ad29f8d940ac 100644 --- a/sdks/java/container/boot.go +++ b/sdks/java/container/boot.go @@ -195,9 +195,6 @@ func main() { "-XX:+UseParallelGC", "-XX:+AlwaysActAsServerClassMachine", "-XX:-OmitStackTraceInFastThrow", - // Crash and restart instead of throwing OutOfMemoryError which may be caught by user or - // framework code and leave things in a degraded state. - "-XX:+ExitOnOutOfMemoryError", } enableGoogleCloudProfiler := strings.Contains(options, enableGoogleCloudProfilerOption) @@ -227,18 +224,16 @@ func main() { args = append(args, jammAgentArgs) } - enableHeapDumpsOnOom := false // If heap dumping is enabled, configure the JVM to dump it on oom events. if pipelineOptions, ok := info.GetPipelineOptions().GetFields()["options"]; ok { if heapDumpOption, ok := pipelineOptions.GetStructValue().GetFields()["enableHeapDumps"]; ok { - enableHeapDumpsOnOom = heapDumpOption.GetBoolValue() + if heapDumpOption.GetBoolValue() { + args = append(args, "-XX:+HeapDumpOnOutOfMemoryError", + "-Dbeam.fn.heap_dump_dir="+filepath.Join(dir, "heapdumps"), + "-XX:HeapDumpPath="+filepath.Join(dir, "heapdumps", "heap_dump.hprof")) + } } } - if enableHeapDumpsOnOom { - args = append(args, "-XX:+HeapDumpOnOutOfMemoryError", - "-Dbeam.fn.heap_dump_dir="+filepath.Join(dir, "heapdumps"), - "-XX:HeapDumpPath="+filepath.Join(dir, "heapdumps", "heap_dump.hprof")) - } // Apply meta options const metaDir = "/opt/apache/beam/options"