Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8268873: Unnecessary Vector usage in java.base
Reviewed-by: mullan
  • Loading branch information
turbanoff authored and seanjmullan committed Jul 26, 2021
1 parent 0b12e7c commit b8f79a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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 @@ -284,11 +284,11 @@ public void write(OutputStream out) throws IOException {
public void read(InputStream is) throws IOException {
BufferedReader br = new BufferedReader
(new InputStreamReader(is, UTF_8.INSTANCE));
String line = null;
String line;
String currentJar = null;

/* an ordered list of jar file names */
Vector<String> jars = new Vector<>();
ArrayList<String> jars = new ArrayList<>();

/* read until we see a .jar line */
while((line = br.readLine()) != null && !line.endsWith(".jar"));
Expand Down
Expand Up @@ -39,12 +39,10 @@
import java.net.Proxy;
import java.security.Principal;
import java.security.cert.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.Vector;

import javax.security.auth.x500.X500Principal;

import javax.net.ssl.*;
import sun.net.www.http.HttpClient;
Expand Down Expand Up @@ -148,14 +146,14 @@ final class HttpsClient extends HttpClient
ciphers = null;
} else {
StringTokenizer tokenizer;
Vector<String> v = new Vector<String>();
ArrayList<String> v = new ArrayList<>();

tokenizer = new StringTokenizer(cipherString, ",");
while (tokenizer.hasMoreTokens())
v.addElement(tokenizer.nextToken());
v.add(tokenizer.nextToken());
ciphers = new String [v.size()];
for (int i = 0; i < ciphers.length; i++)
ciphers [i] = v.elementAt(i);
ciphers [i] = v.get(i);
}
return ciphers;
}
Expand All @@ -172,14 +170,14 @@ final class HttpsClient extends HttpClient
protocols = null;
} else {
StringTokenizer tokenizer;
Vector<String> v = new Vector<String>();
ArrayList<String> v = new ArrayList<>();

tokenizer = new StringTokenizer(protocolString, ",");
while (tokenizer.hasMoreTokens())
v.addElement(tokenizer.nextToken());
v.add(tokenizer.nextToken());
protocols = new String [v.size()];
for (int i = 0; i < protocols.length; i++) {
protocols [i] = v.elementAt(i);
protocols [i] = v.get(i);
}
}
return protocols;
Expand Down
9 changes: 4 additions & 5 deletions src/java.base/share/classes/sun/security/pkcs/PKCS7.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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 @@ -578,19 +578,18 @@ public SignerInfo verify(SignerInfo info, byte[] bytes)
public SignerInfo[] verify(byte[] bytes)
throws NoSuchAlgorithmException, SignatureException {

Vector<SignerInfo> intResult = new Vector<>();
ArrayList<SignerInfo> intResult = new ArrayList<>();
for (int i = 0; i < signerInfos.length; i++) {

SignerInfo signerInfo = verify(signerInfos[i], bytes);
if (signerInfo != null) {
intResult.addElement(signerInfo);
intResult.add(signerInfo);
}
}
if (!intResult.isEmpty()) {

SignerInfo[] result = new SignerInfo[intResult.size()];
intResult.copyInto(result);
return result;
return intResult.toArray(result);
}
return null;
}
Expand Down

1 comment on commit b8f79a7

@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.