Bug: does not work if both children are negative

The solution does not work for the tree below (correct answer is -4 but the solution gives -1):

TreeNode root = new TreeNode(-5);
root.left = new TreeNode(-1);
root.left.left = new TreeNode(-3);
root.left.right = new TreeNode(-8);

The issue is, localMax must include one child as long as one of them is non-null, if both children are null we should not update globalMax at all.

Why is the right solution -4? The single-element path -1 should be the max as -1 > -4