Skip to content

Commit

Permalink
Update dependency com.google.errorprone:error_prone_annotations to v2…
Browse files Browse the repository at this point in the history
….23.0 (#2035)

* Update dependency com.google.errorprone:error_prone_annotations to v2.23.0
* Use StandardCharsets.UTF_8

---------

Co-authored-by: Kevin Risden <[email protected]>
  • Loading branch information
solrbot and risdenk committed Oct 24, 2023
1 parent 7526c7c commit 542cf0b
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 32 deletions.
5 changes: 5 additions & 0 deletions gradle/validation/error-prone.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ allprojects { prj ->
// '-Xep:DoNotMockAutoValue:OFF', // we don't use autovalue
// '-Xep:DoNotUseRuleChain:OFF', // todo could be fixed but not easy
// '-Xep:DoubleCheckedLocking:OFF', // todo check if useful or comment why not
'-Xep:DuplicateDateFormatField:WARN',
'-Xep:EmptyBlockTag:WARN',
// '-Xep:EmptyCatch:OFF', // todo check if useful or comment why not - might be handled by ECJ?
// '-Xep:EmptySetMultibindingContributions:OFF', // we don't use this annotation
Expand Down Expand Up @@ -420,6 +421,7 @@ allprojects { prj ->
// '-Xep:NonAtomicVolatileUpdate:OFF', // todo check if useful or comment why not
'-Xep:NonCanonicalType:WARN',
'-Xep:NonOverridingEquals:WARN',
//'-Xep:NonFinalStaticField:WARN', // todo there are problems that should be fixed
'-Xep:NotJavadoc:WARN',
'-Xep:NullOptional:WARN',
// '-Xep:NullableConstructor:OFF', // we don't use this annotation
Expand Down Expand Up @@ -464,7 +466,10 @@ allprojects { prj ->
// '-Xep:StreamResourceLeak:OFF', // todo check if useful or comment why not
'-Xep:StreamToIterable:WARN',
// '-Xep:StringCaseLocaleUsage:OFF', // we have forbiddenapis for that
'-Xep:StringCharset:WARN',
'-Xep:StringFormatWithLiteral:WARN',
// '-Xep:StringSplitter:OFF', // todo check if useful or comment why not - might be able to use forbidden-apis for this?
'-Xep:SuperEqualsIsObjectEquals:WARN',
// '-Xep:SwigMemoryLeak:OFF', // we don't use swig
// '-Xep:SynchronizeOnNonFinalField:OFF', // todo check if useful or comment why not
// '-Xep:ThreadJoinLoop:OFF', // todo check if useful or comment why not
Expand Down
4 changes: 3 additions & 1 deletion solr/core/src/java/org/apache/solr/handler/CatStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ private boolean advanceToNextFileWithData() throws IOException {
new GZIPInputStream(Files.newInputStream(currentFilePath.absolutePath)),
StandardCharsets.UTF_8));
} else {
currentFileLines = FileUtils.lineIterator(currentFilePath.absolutePath.toFile(), "UTF-8");
currentFileLines =
FileUtils.lineIterator(
currentFilePath.absolutePath.toFile(), StandardCharsets.UTF_8.name());
}
if (currentFileLines.hasNext()) return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static Manifest fetchManifest(
NamedList<Object> response = solrClient.request(request);
String manifestJson = (String) response.get("response");
String calculatedSHA512 =
BlobRepository.sha512Digest(ByteBuffer.wrap(manifestJson.getBytes("UTF-8")));
BlobRepository.sha512Digest(ByteBuffer.wrap(manifestJson.getBytes(StandardCharsets.UTF_8)));
if (expectedSHA512.equals(calculatedSHA512) == false) {
throw new SolrException(
ErrorCode.UNAUTHORIZED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.lang.invoke.MethodHandles;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -122,13 +123,13 @@ public void addRepository(String repoName, String uri) throws Exception {
if (packageManager.zkClient.exists(PackageUtils.REPOSITORIES_ZK_PATH, true) == false) {
packageManager.zkClient.create(
PackageUtils.REPOSITORIES_ZK_PATH,
getMapper().writeValueAsString(repos).getBytes("UTF-8"),
getMapper().writeValueAsString(repos).getBytes(StandardCharsets.UTF_8),
CreateMode.PERSISTENT,
true);
} else {
packageManager.zkClient.setData(
PackageUtils.REPOSITORIES_ZK_PATH,
getMapper().writeValueAsString(repos).getBytes("UTF-8"),
getMapper().writeValueAsString(repos).getBytes(StandardCharsets.UTF_8),
true);
}

Expand All @@ -155,7 +156,8 @@ private String getRepositoriesJson(SolrZkClient zkClient)
throws UnsupportedEncodingException, KeeperException, InterruptedException {
if (zkClient.exists(PackageUtils.REPOSITORIES_ZK_PATH, true)) {
return new String(
zkClient.getData(PackageUtils.REPOSITORIES_ZK_PATH, null, null, true), "UTF-8");
zkClient.getData(PackageUtils.REPOSITORIES_ZK_PATH, null, null, true),
StandardCharsets.UTF_8);
}
return "[]";
}
Expand Down Expand Up @@ -191,10 +193,11 @@ private boolean installPackage(String packageName, String version) throws SolrEx
}
String manifestJson = getMapper().writeValueAsString(release.manifest);
String manifestSHA512 =
BlobRepository.sha512Digest(ByteBuffer.wrap(manifestJson.getBytes("UTF-8")));
BlobRepository.sha512Digest(
ByteBuffer.wrap(manifestJson.getBytes(StandardCharsets.UTF_8)));
PackageUtils.postFile(
solrClient,
ByteBuffer.wrap(manifestJson.getBytes("UTF-8")),
ByteBuffer.wrap(manifestJson.getBytes(StandardCharsets.UTF_8)),
String.format(Locale.ROOT, "/package/%s/%s/%s", packageName, version, "manifest.json"),
null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
Expand Down Expand Up @@ -159,6 +160,6 @@ protected void handleException(Logger log) {

/** Decode URL-encoded strings as UTF-8, and avoid converting "+" to space */
protected static String urlDecode(String str) throws UnsupportedEncodingException {
return URLDecoder.decode(str.replace("+", "%2B"), "UTF-8");
return URLDecoder.decode(str.replace("+", "%2B"), StandardCharsets.UTF_8);
}
}
8 changes: 2 additions & 6 deletions solr/core/src/java/org/apache/solr/rest/RestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -253,11 +253,7 @@ public ManagedEndpoint(RestManager restManager) {
/** Determines the ManagedResource resourceId from the request path. */
public static String resolveResourceId(final String path) {
String resourceId;
try {
resourceId = URLDecoder.decode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); // shouldn't happen
}
resourceId = URLDecoder.decode(path, StandardCharsets.UTF_8);

int at = resourceId.indexOf("/schema");
if (at == -1) {
Expand Down
6 changes: 3 additions & 3 deletions solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -451,7 +451,7 @@ protected void extractHandlerFromURLPath(SolrRequestParsers parser) throws Excep
}

protected void extractRemotePath(String collectionName, String origCorename)
throws UnsupportedEncodingException, KeeperException, InterruptedException, SolrException {
throws KeeperException, InterruptedException, SolrException {
assert core == null;
coreUrl = getRemoteCoreUrl(collectionName, origCorename);
// don't proxy for internal update requests
Expand All @@ -462,7 +462,7 @@ protected void extractRemotePath(String collectionName, String origCorename)
// it does not make sense to send the request to a remote node
throw new SolrException(
SolrException.ErrorCode.INVALID_STATE,
new String(Utils.toJSON(invalidStates), org.apache.lucene.util.IOUtils.UTF_8));
new String(Utils.toJSON(invalidStates), StandardCharsets.UTF_8));
}
action = REMOTEQUERY;
} else {
Expand Down
3 changes: 1 addition & 2 deletions solr/core/src/java/org/apache/solr/update/UpdateLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -999,7 +998,7 @@ public synchronized long applyPartialUpdates(
entry
+ " is not a partial doc"
+ ", while looking for id="
+ new String(id.bytes, Charset.forName("UTF-8")));
+ new String(id.bytes, StandardCharsets.UTF_8));
}
// This update is an inplace update, get the partial doc. The input doc is always at last
// position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -585,7 +586,7 @@ public void testColStatus() throws Exception {
cluster.waitForActiveCollection(collectionName, 2, 4);

SolrClient client = cluster.getSolrClient();
byte[] binData = collectionName.getBytes("UTF-8");
byte[] binData = collectionName.getBytes(StandardCharsets.UTF_8);
// index some docs
for (int i = 0; i < 10; i++) {
SolrInputDocument doc = new SolrInputDocument();
Expand Down
12 changes: 9 additions & 3 deletions solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -129,7 +130,7 @@ public void testSimpleRestore() throws Exception {
.getCoreContainer()
.getAllowPaths()
.add(Path.of(location)); // Allow core to be created outside SOLR_HOME
params += "&location=" + URLEncoder.encode(location, "UTF-8");
params += "&location=" + URLEncoder.encode(location, StandardCharsets.UTF_8);
}

// named snapshot vs default snapshot name
Expand Down Expand Up @@ -189,7 +190,8 @@ public void testSimpleRestore() throws Exception {

public void testBackupFailsMissingAllowPaths() throws Exception {
final String params =
"&location=" + URLEncoder.encode(createTempDir().toFile().getAbsolutePath(), "UTF-8");
"&location="
+ URLEncoder.encode(createTempDir().toFile().getAbsolutePath(), StandardCharsets.UTF_8);
Throwable t =
expectThrows(
IOException.class,
Expand All @@ -208,7 +210,11 @@ public void testFailedRestore() throws Exception {
String location = createTempDir().toFile().getAbsolutePath();
leaderJetty.getCoreContainer().getAllowPaths().add(Path.of(location));
String snapshotName = TestUtil.randomSimpleString(random(), 1, 5);
String params = "&name=" + snapshotName + "&location=" + URLEncoder.encode(location, "UTF-8");
String params =
"&name="
+ snapshotName
+ "&location="
+ URLEncoder.encode(location, StandardCharsets.UTF_8);
String baseUrl = leaderJetty.getBaseUrl().toString();

TestReplicationHandlerBackup.runBackupCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.solr.servlet;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -65,7 +66,11 @@ public void testInsertThenSelect() throws Exception {
// Test using the Stream body parameter
for (String cmd : cmds) {
direct.request(
"/update?" + CommonParams.STREAM_BODY + "=" + URLEncoder.encode(cmd, "UTF-8"), null);
"/update?"
+ CommonParams.STREAM_BODY
+ "="
+ URLEncoder.encode(cmd, StandardCharsets.UTF_8),
null);
}
String got = direct.request(getIt, null);
assertTrue(got.indexOf(value) > 0);
Expand Down
1 change: 0 additions & 1 deletion solr/licenses/error_prone_annotations-2.22.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions solr/licenses/error_prone_annotations-2.23.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
43a27853b6c7d54893e0b1997c2c778c347179eb
4 changes: 2 additions & 2 deletions solr/modules/hdfs/src/test/org/apache/hadoop/fs/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ private static void runCommandOnStream(
try (BufferedReader reader =
new BufferedReader(
new InputStreamReader(process.getInputStream(),
Charset.forName("UTF-8")))) {
StandardCharsets.UTF_8))) {
String line;
while((line = reader.readLine()) != null) {
LOG.debug(line);
Expand All @@ -759,7 +759,7 @@ private static void runCommandOnStream(
try (BufferedReader reader =
new BufferedReader(
new InputStreamReader(process.getErrorStream(),
Charset.forName("UTF-8")))) {
StandardCharsets.UTF_8))) {
String line;
while((line = reader.readLine()) != null) {
LOG.debug(line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -497,7 +498,7 @@ private void addReplicaToReplicasMap(Block block, ReplicaMap volumeMap,
File.pathSeparator + "." + file.getName() + ".restart");
Scanner sc = null;
try {
sc = new Scanner(restartMeta, "UTF-8");
sc = new Scanner(restartMeta, StandardCharsets.UTF_8);
// The restart meta file exists
if (sc.hasNextLong() && (sc.nextLong() > timer.now())) {
// It didn't expire. Load the replica as a RBW.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
Expand Down Expand Up @@ -124,7 +125,7 @@ protected URI processUrl(String url) throws SQLException {
}

private void loadParams(URI uri, Properties props) throws SQLException {
List<NameValuePair> parsedParams = URLEncodedUtils.parse(uri, "UTF-8");
List<NameValuePair> parsedParams = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8);
for (NameValuePair pair : parsedParams) {
if (pair.getValue() != null) {
props.put(pair.getName(), pair.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
Expand Down Expand Up @@ -139,7 +140,7 @@ public byte[] httpRequest(
final HttpRequestBase req;
HttpEntity entity = null;
if (payload != null) {
entity = new StringEntity(payload, "UTF-8");
entity = new StringEntity(payload, StandardCharsets.UTF_8);
}
switch (method) {
case GET:
Expand Down
2 changes: 1 addition & 1 deletion versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ com.google.cloud:google-cloud-core-grpc:2.23.0 (1 constraints: 1b1002a6)
com.google.cloud:google-cloud-core-http:2.23.0 (1 constraints: 1b1002a6)
com.google.cloud:google-cloud-storage:2.27.0 (2 constraints: d71c8a27)
com.google.code.gson:gson:2.10.1 (8 constraints: 7c6bf476)
com.google.errorprone:error_prone_annotations:2.22.0 (11 constraints: b286c424)
com.google.errorprone:error_prone_annotations:2.23.0 (11 constraints: b286c424)
com.google.guava:failureaccess:1.0.1 (2 constraints: f9199e37)
com.google.guava:guava:32.1.3-jre (26 constraints: 417ba570)
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (2 constraints: 4b35b0a0)
Expand Down
2 changes: 1 addition & 1 deletion versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ com.github.ben-manes.caffeine:caffeine=3.1.8
com.github.spotbugs:*=4.8.0
com.github.stephenc.jcip:jcip-annotations=1.0-1
com.google.cloud:google-cloud-bom=0.204.0
com.google.errorprone:*=2.22.0
com.google.errorprone:*=2.23.0
com.google.guava:guava=32.1.3-jre
com.google.re2j:re2j=1.7
com.jayway.jsonpath:json-path=2.8.0
Expand Down

0 comments on commit 542cf0b

Please sign in to comment.