mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8290300: Use standard String-joining tools where applicable
Reviewed-by: naoto, rriggs, dfuchs
This commit is contained in:
parent
f9004fe443
commit
9a65524e2f
4 changed files with 6 additions and 18 deletions
|
@ -34,7 +34,6 @@ import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringJoiner;
|
|
||||||
import jdk.internal.event.ProcessStartEvent;
|
import jdk.internal.event.ProcessStartEvent;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
|
|
||||||
|
@ -1114,12 +1113,8 @@ public final class ProcessBuilder
|
||||||
redirectErrorStream);
|
redirectErrorStream);
|
||||||
ProcessStartEvent event = new ProcessStartEvent();
|
ProcessStartEvent event = new ProcessStartEvent();
|
||||||
if (event.isEnabled()) {
|
if (event.isEnabled()) {
|
||||||
StringJoiner command = new StringJoiner(" ");
|
|
||||||
for (String s: cmdarray) {
|
|
||||||
command.add(s);
|
|
||||||
}
|
|
||||||
event.directory = dir;
|
event.directory = dir;
|
||||||
event.command = command.toString();
|
event.command = String.join(" ", cmdarray);
|
||||||
event.pid = process.pid();
|
event.pid = process.pid();
|
||||||
event.commit();
|
event.commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ import java.io.Serializable;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.spi.LocaleNameProvider;
|
import java.util.spi.LocaleNameProvider;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import jdk.internal.vm.annotation.Stable;
|
import jdk.internal.vm.annotation.Stable;
|
||||||
|
|
||||||
|
@ -2335,7 +2334,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||||
// If we have no list patterns, compose the list in a simple,
|
// If we have no list patterns, compose the list in a simple,
|
||||||
// non-localized way.
|
// non-localized way.
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
return Arrays.stream(stringList).collect(Collectors.joining(","));
|
return String.join(",", stringList);
|
||||||
}
|
}
|
||||||
|
|
||||||
return switch (stringList.length) {
|
return switch (stringList.length) {
|
||||||
|
|
|
@ -1536,11 +1536,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||||
}
|
}
|
||||||
List<String> l = entry.getValue();
|
List<String> l = entry.getValue();
|
||||||
if (l != null && !l.isEmpty()) {
|
if (l != null && !l.isEmpty()) {
|
||||||
StringJoiner cookieValue = new StringJoiner("; ");
|
requests.add(key, String.join("; ", l));
|
||||||
for (String value : l) {
|
|
||||||
cookieValue.add(value);
|
|
||||||
}
|
|
||||||
requests.add(key, cookieValue.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -704,11 +704,9 @@ class WindowsPath implements Path {
|
||||||
if (beginIndex >= endIndex)
|
if (beginIndex >= endIndex)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringJoiner sb = new StringJoiner("\\");
|
||||||
for (int i = beginIndex; i < endIndex; i++) {
|
for (int i = beginIndex; i < endIndex; i++) {
|
||||||
sb.append(elementAsString(i));
|
sb.add(elementAsString(i));
|
||||||
if (i != (endIndex-1))
|
|
||||||
sb.append("\\");
|
|
||||||
}
|
}
|
||||||
return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", sb.toString());
|
return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", sb.toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue