Skip to content

Commit

Permalink
8290300: Use standard String-joining tools where applicable
Browse files Browse the repository at this point in the history
Reviewed-by: naoto, rriggs, dfuchs
  • Loading branch information
stsypanov authored and cl4es committed Aug 21, 2022
1 parent f9004fe commit 9a65524
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
7 changes: 1 addition & 6 deletions src/java.base/share/classes/java/lang/ProcessBuilder.java
Expand Up @@ -34,7 +34,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import jdk.internal.event.ProcessStartEvent;
import sun.security.action.GetPropertyAction;

Expand Down Expand Up @@ -1114,12 +1113,8 @@ private Process start(Redirect[] redirects) throws IOException {
redirectErrorStream);
ProcessStartEvent event = new ProcessStartEvent();
if (event.isEnabled()) {
StringJoiner command = new StringJoiner(" ");
for (String s: cmdarray) {
command.add(s);
}
event.directory = dir;
event.command = command.toString();
event.command = String.join(" ", cmdarray);
event.pid = process.pid();
event.commit();
}
Expand Down
3 changes: 1 addition & 2 deletions src/java.base/share/classes/java/util/Locale.java
Expand Up @@ -48,7 +48,6 @@
import java.text.MessageFormat;
import java.util.concurrent.ConcurrentHashMap;
import java.util.spi.LocaleNameProvider;
import java.util.stream.Collectors;

import jdk.internal.vm.annotation.Stable;

Expand Down Expand Up @@ -2335,7 +2334,7 @@ private static String formatList(String[] stringList, String pattern) {
// If we have no list patterns, compose the list in a simple,
// non-localized way.
if (pattern == null) {
return Arrays.stream(stringList).collect(Collectors.joining(","));
return String.join(",", stringList);
}

return switch (stringList.length) {
Expand Down
Expand Up @@ -1536,11 +1536,7 @@ private void setCookieHeader() throws IOException {
}
List<String> l = entry.getValue();
if (l != null && !l.isEmpty()) {
StringJoiner cookieValue = new StringJoiner("; ");
for (String value : l) {
cookieValue.add(value);
}
requests.add(key, cookieValue.toString());
requests.add(key, String.join("; ", l));
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/java.base/windows/classes/sun/nio/fs/WindowsPath.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -704,11 +704,9 @@ public WindowsPath subpath(int beginIndex, int endIndex) {
if (beginIndex >= endIndex)
throw new IllegalArgumentException();

StringBuilder sb = new StringBuilder();
StringJoiner sb = new StringJoiner("\\");
for (int i = beginIndex; i < endIndex; i++) {
sb.append(elementAsString(i));
if (i != (endIndex-1))
sb.append("\\");
sb.add(elementAsString(i));
}
return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", sb.toString());
}
Expand Down

1 comment on commit 9a65524

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.