Skip to content

Commit

Permalink
Throw IllegalArgumentException when removing null child from figure
Browse files Browse the repository at this point in the history
The Figure#remove() method throws a NullPointerException when trying to
remove a "null" child, due to a call to figure.getParent(). To remain
consistent with the case where the child belongs to a different parent,
this should also throw an IllegalArgumentException.
  • Loading branch information
ptziegler authored and azoitl committed Aug 9, 2024
1 parent 65ae50f commit 4a6c119
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion org.eclipse.draw2d/src/org/eclipse/draw2d/Figure.java
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ protected void primTranslate(int dx, int dy) {
*/
@Override
public void remove(IFigure figure) {
if ((figure.getParent() != this)) {
if (figure == null || figure.getParent() != this) {
throw new IllegalArgumentException("Figure is not a child"); //$NON-NLS-1$
}
if (getFlag(FLAG_REALIZED)) {
Expand Down

0 comments on commit 4a6c119

Please sign in to comment.