Skip to content

Commit

Permalink
Bug 582305 Improve Leak Suspects report for references in paths
Browse files Browse the repository at this point in the history
Fix command printing for commands such as:
path2gc 0x0 -exclude;
where the -exclude was omitted leading to default values being used
next time.

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=582305
Change-Id: I4c3f00312e88653db9abedce0f63fe383c628340
  • Loading branch information
ajohnson1 committed Sep 22, 2023
1 parent 094627d commit 1d9a40c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1018,12 +1018,16 @@ else if (path.length > 1)

void addExcludes(StringBuilder sb)
{
if (excludes != null && !excludes.isEmpty())
boolean hasDefault = true;
if (excludes != null && !excludes.isEmpty() || hasDefault)
{
sb.append(" -excludes"); //$NON-NLS-1$
for (String ex : excludes)
if (excludes != null)
{
sb.append(' ').append(Converters.convertAndEscape(String.class, ex));
for (String ex : excludes)
{
sb.append(' ').append(Converters.convertAndEscape(String.class, ex));
}
}
sb.append(';');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2022 SAP AG and IBM Corporation.
* Copyright (c) 2008, 2023 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -9,7 +9,7 @@
*
* Contributors:
* SAP AG - initial API and implementation
* IBM Corporation - documentation
* IBM Corporation - documentation and more argument processing
*******************************************************************************/
package org.eclipse.mat.query.registry;

Expand Down Expand Up @@ -222,7 +222,11 @@ void appendUsage(StringBuilder buf, Object value)
return;
}

if (isMultiple() && (value == null || ((List<?>) value).isEmpty())) return;
// If the supplied argument is missing/null/empty, saying the value of this argument is we cannot omit it if is non-mandatory and the default is non-empty
// Otherwise the default will take effect
if (isMultiple() && (value == null || isList() && ((List<?>) value).isEmpty()) && !isMandatory()
&& getDefaultValue() == null)
return;

buf.append(" ");

Expand Down Expand Up @@ -257,6 +261,7 @@ else if (v instanceof ArgumentFactory)
buf.append(Converters.convertAndEscape(type, v)).append(" ");
}
}
buf.append("; ");
}
else
{
Expand Down

0 comments on commit 1d9a40c

Please sign in to comment.