diff options
author | Alexander Kurtakov | 2020-01-07 22:23:58 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2020-01-10 21:21:17 +0000 |
commit | 6a74744884e5cbdd5778040532cc1a0f6f698f7b (patch) | |
tree | 50c8261591870ada87240a33cca332233bcb98f4 | |
parent | 790e31afa88c777f9a265c987a3d3c43bc09cbc6 (diff) | |
download | rt.equinox.p2-6a74744884e5cbdd5778040532cc1a0f6f698f7b.tar.gz rt.equinox.p2-6a74744884e5cbdd5778040532cc1a0f6f698f7b.tar.xz rt.equinox.p2-6a74744884e5cbdd5778040532cc1a0f6f698f7b.zip |
Use System.lineSeparator()Y20200114-0045I20200113-1800I20200113-0130I20200112-1800I20200111-1800I20200111-0325I20200111-0230I20200110-1805
Benefit of this way rather than System.getProperty("line.separator") is
that there are no security checks.
Change-Id: I2807af3be704e02cb541da6b579214cb13d6194e
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
7 files changed, 33 insertions, 22 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java index 3705a864a..701fb3427 100644 --- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java +++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java @@ -176,7 +176,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener { private static final String QUERY_SEPARATOR = "Q:"; //$NON-NLS-1$ private static final String QUERY_SEPARATOR_SMALL = "q:"; //$NON-NLS-1$ - public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ + public static final String LINE_SEPARATOR = System.lineSeparator(); private static void getURIs(List<URI> uris, String spec) throws CoreException { if (spec == null) diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java index 22c5b13de..caf6b4cca 100644 --- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java +++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java @@ -31,7 +31,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; public class IUListFormatter { private static final String PREFIX = "${"; //$NON-NLS-1$ - private static final String LINE_SEP = System.getProperty("line.separator"); //$NON-NLS-1$ + private static final String LINE_SEP = System.lineSeparator(); private String formatString; private Collection<String> properties; diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java index 20bf19e4f..f4472ab2a 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java @@ -26,7 +26,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.osgi.service.debug.DebugOptions; public class DebugHelper { - public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ + public static final String LINE_SEPARATOR = System.lineSeparator(); public static final boolean DEBUG_PROFILE_REGISTRY; public static final boolean DEBUG_ENGINE; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java index 9bd77d3ff..460955b9c 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java @@ -22,7 +22,7 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; public class FileMirrorLog implements IArtifactMirrorLog { private static final String INDENT = "\t"; //$NON-NLS-1$ - private static final String SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ + private static final String SEPARATOR = System.lineSeparator(); private BufferedWriter out; private boolean consoleMessage = false; private int minSeverity = IStatus.OK; diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/DebugHelper.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/DebugHelper.java index 3cef71ce3..bb422888a 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/DebugHelper.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/DebugHelper.java @@ -21,7 +21,7 @@ import org.eclipse.equinox.internal.p2.repository.Activator; import org.eclipse.osgi.service.debug.DebugOptions; public class DebugHelper { - public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ + public static final String LINE_SEPARATOR = System.lineSeparator(); public static final boolean DEBUG_REPOSITORY_CREDENTIALS; public static final boolean DEBUG_REPOSITORY_TRANSPORT; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java index e2c8f2048..847eaa6c1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/IUListFormatterTest.java @@ -14,9 +14,16 @@ package org.eclipse.equinox.p2.tests.director; import static java.util.Arrays.asList; -import static org.easymock.EasyMock.*; - -import java.util.*; +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.createNiceMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.getCurrentArguments; +import static org.easymock.EasyMock.replay; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import junit.framework.TestCase; import org.easymock.IAnswer; import org.eclipse.equinox.internal.p2.director.app.IUListFormatter; @@ -37,7 +44,7 @@ public class IUListFormatterTest extends TestCase { createIU("iu1", "1.0.0", "name", null), // createIU("iu2", "2.0.0", "name2", null)// )); - assertEquals("iu1=1.0.0,name" + System.getProperty("line.separator") + "iu2=2.0.0,name2", result); + assertEquals("iu1=1.0.0,name" + System.lineSeparator() + "iu2=2.0.0,name2", result); } public void testFormat_UnknownFormatOption() { diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/CopyUtils.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/CopyUtils.java index e1d2c2a51..d4b13da3f 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/CopyUtils.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/CopyUtils.java @@ -27,7 +27,7 @@ import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.swt.IFocusService; public class CopyUtils { - public static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ + public static final String NEWLINE = System.lineSeparator(); public static final String DELIMITER = "\t"; //$NON-NLS-1$ private static final String NESTING_INDENT = " "; //$NON-NLS-1$ @@ -46,8 +46,9 @@ public class CopyUtils { } /** - * Install a copy popup menu on the specified control and activate the copy handler for the control when - * the control has focus. The handler will be deactivated when the control is disposed. + * Install a copy popup menu on the specified control and activate the copy + * handler for the control when the control has focus. The handler will be + * deactivated when the control is disposed. * * @param copyable the copyable that will perform the copy * @param control the control on which to install the menu and handler @@ -58,18 +59,21 @@ public class CopyUtils { new CopyPopup(copyable, control); if (fs != null && hs != null) { fs.addFocusTracker(control, CONTROL_ID); - final IHandlerActivation handlerActivation = hs.activateHandler(CopyHandler.ID, new CopyHandler(copyable), new Expression() { - @Override - public EvaluationResult evaluate(IEvaluationContext context) { - return context.getVariable(ISources.ACTIVE_FOCUS_CONTROL_NAME) == control ? EvaluationResult.TRUE : EvaluationResult.FALSE; - } + final IHandlerActivation handlerActivation = hs.activateHandler(CopyHandler.ID, new CopyHandler(copyable), + new Expression() { + @Override + public EvaluationResult evaluate(IEvaluationContext context) { + return context.getVariable(ISources.ACTIVE_FOCUS_CONTROL_NAME) == control + ? EvaluationResult.TRUE + : EvaluationResult.FALSE; + } - @Override - public void collectExpressionInfo(final ExpressionInfo info) { - info.addVariableNameAccess(ISources.ACTIVE_FOCUS_CONTROL_NAME); - } + @Override + public void collectExpressionInfo(final ExpressionInfo info) { + info.addVariableNameAccess(ISources.ACTIVE_FOCUS_CONTROL_NAME); + } - }); + }); control.addDisposeListener(e -> hs.deactivateHandler(handlerActivation)); } } |